I have a PDO statement that insert or update a row depending on a UNIQUE column (if the column exist then update) . I wonder if there is a solution for both to get the id of the INSERTED or UPDATED that I could use in the same query. So ... considering this answer ... how could it be together?
SET @update_id := 0;
UPDATE some_table SET column_name = 'value', id = (SELECT @update_id := id)
WHERE some_other_column = 'blah' LIMIT 1;
SELECT @update_id;
plus
lastInsertId();
meaning something like (I'm not sure if there would be a sintax for this so I just set what i have in mind:
IF "INSERT" then SELECT lastInsertId()
else if "UPDATE" then select ID of the last row updated;