SQL中如何使⽤UPDATE语句进⾏联表更新(转)
在本例中: 我们要⽤表member中的name,age字段数据去更新user中的同字段名的数据,条件是当user 中的id字段值与member中的id字段值相等时进⾏更新.
mysql语句转oracleSQL Server语法: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 ] ) ]
SQL Server⽰例: update a set a.name=b.name,a.age=b.age from user a,member b where a.id=b.id
Oracle语法: UPDATE updatedtable SET (col_name1[,])= (SELECT col_name1,[,] FROM srctable [WHERE where_definition])
Oracel ⽰例_1: update user a set (a.name, a.age)= (select b.name, b.age from member b where a.id=b.id)
Oracel ⽰例_2:sumif是什么公式
switch英文二进制逻辑运算xor( 查询出HX_CASH_PRECONTRACT表中custname为NULL的记录,并将HX_FINANCE_ACCOUNT表中的custname的值赋予该字段) UPDATE hx_cash_precontract a SET (a.custname) = (SELECT b.custname FROM hx_finance_account b WHERE a.pk_finance_account = b.pk_finance_account) WHERE a.custname IS NULL
MySQL语法: UPDATE table_references SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition]面试问shell脚本写什么
MySQL ⽰例: update user a, member b set a.name= b.name, a.age= b.age where a.id=b.id
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论