当前位置:   article > 正文

SQL Update多表联合修改_sql多表查询 修改

sql多表查询 修改

1) Oracle 多表更新方法:

     Oracle语法: UPDATE updatedtable SET (col_name1[,col_name2...])= (SELECT col_name1,[,col_name2...] FROM srctable [WHERE where_definition])

     例子:UPDATE A a  SET (a.a1,a.a2)=(SELECT b.b1,b,b2 FROM B b WHERE b.b3=a.a3)


2) MySql多表更新方法:

    MySql语法:UPDATE table_references SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition]

   例子:UPDATE A a , B b SET a.a1 = b.b1 , a.a2 = b.b2 WHERE a.a3 = b.b3


3) SQLServer多表更新方法:

  SQLServer语法:UPDATE { table_name WITH ( < table_hint_limited > [ ...n ] ) | view_name | rowset_function_limited } SET { column_name = { expression | DEFAULT | NULL } | @variable = expression | @variable = column = expression } [ ,...n ] { { [ FROM { < table_source > } [ ,...n ] ] [ WHERE < search_condition > ] } | [ WHERE CURRENT OF { { [ GLOBAL ] cursor_name } | cursor_variable_name } ] } [ OPTION ( < query_hint > [ ,...n ] ) ]

  例子:UPDATE a SET a.a1 = b.b1 , a.a2 = b.b2 FROM A a , B b WHERE a.a3 = b.b3

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/758206
推荐阅读