SQL用另外乙個表的資料更新本表資料

2021-05-26 19:07:57 字數 328 閱讀 8445

update s set s.classbid = lc.itemid

from    dbo.lv_servers as s inner join

dbo.lv_linechannel as lc on s.classsid = lc.classid where s.classbid >0

sql用另外乙個表的資料更新本表資料,兩個表的關係要寫在from的後面表的別名也要寫在這裡,寫在update後面是不行的,update後面跟著要更新的表,至於同時更新兩表的資料暫時沒有用過就 不知道了。

用乙個表的記錄更新另外乙個表

用table 1的address,phone number更新table 2的address,phone number,注意 1.set 後面加上要更新的列,有多個要更新的列時,加上多個列,2.where 後面加上table 1和table 2的關聯列,有多個關聯列時,加上多個列 3.rownum用...

根據乙個表的字段,更新另外乙個表的字段

update table a set latesttm u.tm,latestdata u.data from select from table b inner join select max tm newesttm from table b group by stcd v on drp.tm v...

SQL查詢乙個表中另外乙個表不存在的資料。

現在有乙個業務場景,兩張表sy user 表 sy org表 其中sy org表的orgid sy user表的username 現在有乙個需求 要求剔除 a表中 user 相對於b表 org 表 多餘的資料 根據對應關係 編寫sql 查詢出兩張表中的重複項 select distinct u.us...