MERGE INTO [your table-name] [rename your table here]     
USING ( [write your query here] )[rename your query-sql and using just like a table] ON ([conditional expression here] AND [...]...)     
WHEN MATHED THEN [here you can execute some update sql or something else ]
WHEN NOT MATHED THEN [execute something else here ! ] 

例如:

MERGE INTO table1 a USING ( select id,name from table2) b ON (a.id=b.id)     
WHEN MATHED THEN update set a.name=b.name
WHEN NOT MATHED THEN insert (id,name) values('id','name');

解析:

匹配table1 a,用b这个查询结果,用on建立联系,当匹配上用update,匹配不上用insert。

相关文章:

  • 2022-01-17
  • 2021-04-21
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案