Home > database > The MERGE to a deal with another batch of new data comparison table?
The MERGE to a deal with another batch of new data comparison table?
Time:02-21
At present is that the bulk of new data, the first row and list A heavy, don't repeat is inserted INTO A table in A
MERGE INTO A table USING existing (SELECT '1 nhxjrvkxvz2gear12in8aaxk69cae9l41' d UNION ALL SELECT '1 jb4sxtfwpdyw4o1abudfurcpsq4thjjfg' d UNION ALL SELECT '1 kveonm2cvpktpbmeykguheenwccfcyvjc' d UNION ALL SELECT '19 b1tyo63gfvzep85kq18vgpybznkqe72x' d) Add ON (=new existing. Address. D) the WHEN NOT MATCHED THEN INSERT (address) VALUES (new. D);
need to add A logic: assuming that receives the client to come over to 100 data, complete row behind 20 pairs of data preparation to be heavy to form A new, now will this article 20 record again and table B do the contrast, if records exist in B, to mark them A mark used in the future,
CodePudding user response:
Inside the new there add a left join table put together mark in b
CodePudding user response:
Probably mean it
MERGE INTO A table USING existing (the SELECT temp1. D, b. marked * FROM (SELECT '1 nhxjrvkxvz2gear12in8aaxk69cae9l41' d UNION ALL SELECT '1 jb4sxtfwpdyw4o1abudfurcpsq4thjjfg' d UNION ALL SELECT '1 kveonm2cvpktpbmeykguheenwccfcyvjc' d UNION ALL SELECT '19 b1tyo63gfvzep85kq18vgpybznkqe72x' d) temp1 LEFT JOIN b ON temp1. Col=biggest ol) Add ON (=new existing. Address. D) the WHEN NOT MATCHED THEN INSERT (address, mark) VALUES (new. D, new. Mark);