OUTPUT Clause in MySQL

  1. You could create a trigger and insert values you need into another table.
  2. I’m not sure, but – for MYISAM tables you could lock employee table, select and insert values into another table, and then update and unlock employee table.

EDIT:

I have tried one scenario with InnoDb table, seems it works –

START TRANSACTION;

SELECT * FROM table WHERE id = 1 FOR UPDATE; -- lock rows
-- Or call this select to insert and lock rows
-- INSERT INTO table_output SELECT * FROM table WHERE id = 1 FOR UPDATE;

-- Make modifications
UPDATE table SET column1 = '111' WHERE id = 1;

COMMIT;

SELECT statement (FOR UPDATE clause)

Leave a Comment