Guest User

Untitled

a guest
Oct 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. INSERT INTO table1 (title) SELECT title from table2 WHERE ...
  2.  
  3. UPDATE table2 SET status='Used'
  4.  
  5. start transaction;
  6. insert into table1(title) select title from table2 where foo=bar for update;
  7. update table2 set status= 'Used' where foo=bar;
  8. commit;
  9.  
  10. INSERT INTO table1 (title)
  11. SELECT title FROM table2
  12. ON DUPLICATE KEY UPDATE status = 'Used'
Add Comment
Please, Sign In to add comment