Any help with writing the query described below would be most appreciated. Thanks in advance.
I have two tables to hold and index of uploaded photographs for a online real estate site. Table one (photos) holds all the individual data for each photograph. Table 2 (photos_ind) matches the photos with their respective listings.
In my case "id_num" is the master key for listings in my application. For each listing there is a variable number of photographs. I determine the designation of which photograph I am dealing with in my application with the "des" field in the "photos" table.
I have figured out the part that creates the queries and uploads the info to the database, however I cannot seem to write a query that works to delete all photos that are related to a specific "id_num" with a specific designation "des".
How can I, with the table structure below, write a query that would delete all entries in both the photos table and photos_ind table associated with a particular "id_num" and "des". This has been driving me crazy. Also, while we are at it, how could we write a query that would update instead of delete?
TABLE 1 (photos):
filename
des
height
width
hw
size
TABLE 2 (photos_ind):
id_num
filename
I tried something like the following but recieved a generic syntax error:
DELETE FROM photos, photos_ind
WHERE photos.des = $des
AND photos_ind.id_num = $id_num
AND photos_ind.filename = photos.filename
I also tried this and recieved an error:
DELETE filename, des, height, width, hw, size
FROM photos, photos_ind
WHERE photos.des = $des
AND photos_ind.id_num = $id_num
AND photos_ind.filename = photos.filename
I have two tables to hold and index of uploaded photographs for a online real estate site. Table one (photos) holds all the individual data for each photograph. Table 2 (photos_ind) matches the photos with their respective listings.
In my case "id_num" is the master key for listings in my application. For each listing there is a variable number of photographs. I determine the designation of which photograph I am dealing with in my application with the "des" field in the "photos" table.
I have figured out the part that creates the queries and uploads the info to the database, however I cannot seem to write a query that works to delete all photos that are related to a specific "id_num" with a specific designation "des".
How can I, with the table structure below, write a query that would delete all entries in both the photos table and photos_ind table associated with a particular "id_num" and "des". This has been driving me crazy. Also, while we are at it, how could we write a query that would update instead of delete?
TABLE 1 (photos):
filename
des
height
width
hw
size
TABLE 2 (photos_ind):
id_num
filename
I tried something like the following but recieved a generic syntax error:
DELETE FROM photos, photos_ind
WHERE photos.des = $des
AND photos_ind.id_num = $id_num
AND photos_ind.filename = photos.filename
I also tried this and recieved an error:
DELETE filename, des, height, width, hw, size
FROM photos, photos_ind
WHERE photos.des = $des
AND photos_ind.id_num = $id_num
AND photos_ind.filename = photos.filename