当前位置:网站首页>A way of writing SQL, update when matching, or insert

A way of writing SQL, update when matching, or insert

2022-07-06 23:56:00 lboke

grammar :

MERGE INTO (  ) A 
  USING (
      
    ) B ON ( ) 

 WHEN MATCHED THEN 
        Write update statements or other statements :UPDATE  SET ....

 WHEN NOT MATCHED THEN  

     Write insert statements or other statements :
    INSERT (  Field   ) VALUES(    data source  );

 

analysis :

MERGE INTO (  Query all the data  ) A 
  USING (
        Query the data to be compared or matched SQL
    ) B ON ( Data matching or comparison , such as  A = B ) 

 WHEN MATCHED THEN  --  The meaning of this match is to update the statement 
        Write update statements or other statements :UPDATE  SET ....

 WHEN NOT MATCHED THEN  --  This means that the insert statement is executed after the mismatch 

     Write insert statements or other statements :
    INSERT (  Field   ) VALUES(    data source  );

 

原网站

版权声明
本文为[lboke]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061630464975.html