sql - Need MySQL query to update/add record into table1 from table2 -
i want mysql query update/add table1 if data exist in table2
if record not exist in table1 add record (from table2) otherwise update it.
thanking in advance.
you can copy entries table2 table1 using following syntax, assuming id primary key of tables:
insert table1 select * table2 id not in (select id table1);
the update-query not generic:
update table1 set <col>=(select <col> table2 table1.id=table2.id);
you'll have perform above update query each column in tables.
Comments
Post a Comment