Skip to content

Instantly share code, notes, and snippets.

View IgorTimofeev's full-sized avatar
🤔
.!.

IgorTimofeev

🤔
.!.
View GitHub Profile
@PieterScheffers
PieterScheffers / mysql_get_last_updated_id.sql
Created June 21, 2016 10:56
MySQL - Get id of updated rows
# http://stackoverflow.com/questions/1388025/how-to-get-id-of-the-last-updated-row-in-mysql
# single row update
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;
# Multiple rows updated
SET @uids := null;