SQL update 多表連接方法


SQL Update多表聯合更新的方法
(1) sqlite 多表更新方法
//----------------------------------
update t1 set col1=t2.col1
from table1 t1
inner join table2 t2 on t1.col2=t2.col2
這是一個非常簡單的批量更新語句 在SqlServer中支持此語法 sqlite中卻不支持


sqlite中可轉換為 如下語法 
update table1 set col1=(select col1 from table2 where col2=table1.col2)


update ta_jbnt_tzhd_pht_Area_xiang set t1=(select sys_xzqhdm.name from sys_xzqhdm 
 where t2=sys_xzqhdm.code) 


(2) SQL Server 多表更新方法
//----------------------------------
SQL 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.gqdltks=b.gqdltks,a.bztks=b.bztks from
landleveldata a,gdqlpj b where a.GEO_Code=b.lxqdm

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM