# MySQL multi-table update

MySQLupdate

I'm a bit confused about the proper way to update one table, based on the values of corresponding rows in another table.

Here is the query I have:

UPDATE
features,
images
SET
features.deleted = 1
WHERE
features.objectType = 'image'
AND images.id = features.objectId


My goal:

I want to set the features.deleted column value for all rows in the
features table to be 1, only if the corresponding
images.uploaded value for that associated image is 0.

I want to go over all the images that been created in my app, and if
the image wasn't successfully uploaded, I want to delete the
corresponding features record.

I believe this works, but have been having a hard time finding specific examples using my approach (most suggest using joins).

My concern is that the UPDATE query is too general: I just want to make sure that it will only update feature records that have their associated image record with an uploaded value of 0.

Thanks for any guidance/confirmation!

I was correct, and the query above worked as desired. For anyone stumbling on this in the future, the format seemed to work given my context.

UPDATE
features,
images
SET
features.deleted = 1
WHERE
features.objectType = 'image'
AND images.id = features.objectId