I have 2 tables employees
and job
in a MySQL
server. I have 2 CSV
files with the same schema as the two tables. Something as below.
Job table(MySQL)
Job(CSV)
Employees(MySQL)
Employees(CSV)
I need to insert the rows from CSV
into the MySQL
tables. Note that the Id
fields in both the tables are on AUTOINCREMENT
. I am aware that MySQL
does not support merge
query and instead has INSERT.. ON DUPLICATE UPDATE
. Now the issue with using this is that the Primary keys i.e., the Ids are definitely duplicate but I need them to be inserted as new rows with new Ids. For example, the Admin role should have the Id as 3 and so on. Also, as you can see, the job
table is being referenced by the employees
table. So the the JobId
column in the table should be updated with the respective values. I am not sure how this can be achieved.
Any help appreciated!