There are three tables - Table1 , Table2 , Table3 . The tables are absolutely identical in structure, for example, the fields are number_tasks (key field, no matches), customer, task . Table1 is loaded every day from an external source, it has records that are not in Table2 , and in Table2 there are records that are not in Table1 , Table2 is the result. Table1 there are missing entries in Table2 - new tasks. In Table2 there are records that are not in Table1 - solved problems.
Required: in Table2 move the solved tasks to Table3 (add to existing ones) and add new ones from Table1 to Table2 .
"If in Table2 there are no records from Table1, then we add them to Table2 and if in Table1 there are no records from Table2, then from Table2 we transfer them to Table3"
insert into from selectqueries, first 2 β 3 and then 1 β 2. - Alex Krass