sql - MySQL DB migration -
good evening,
i need combine 2 tables school project in mysql workbench. problem 1 table has pk , other not. the 1 without pk has double id , id's exist in table pk id. (note: id not auto increment)
example table a:
id | name | ... ---------------- 1 | test | 11 | test2 | 22 | test4 |
and one.
example table b: (without pk)
id | name ----------- 1 | name1 11 | nam2 0 | nam31 0 | na4e1 0 | nam4 334 | n4e1
table b has id's exist in table , table b has double id numbers...
i wanted following, seems mysql not last inserted id within transaction.
use flyaway; insert staff (`name`, staffnumber, `type`, primaryairport) select flyaway_excel.staff.`name`, flyaway_excel.staff.staffnumber, flyaway_excel.staff.`type`, (select `code` airport `name` = flyaway_excel.staff.primary_airport) flyaway_excel.staff on duplicate key update staffnumber = last_insert_id() + 1;
does know how can in mysql? saw other post told use cursor.. seems mysql workbench not support cursors?
the aprieciated
Comments
Post a Comment