I want to run something like
UPDATE TABLE profile
SET profile_photo = (SELECT photo_id FROM photos WHERE profile_id
= 'someprofileid' ORDER BY photo_id DESC LIMIT 1;)
WHERE 'somecolumn' = 'some criteria'
I have seen Advanced MySql Query: Update table with info from another table
But I only want the last entry which satisfies the WHERE
clause, therefore the DESC
and LIMIT 1
. How do I included these criteria in the SET
information?
(My goal is to update change a profile picture to the most recent profile picture, after e.g a delete or sth)