批量更新

有如下兩個表:
table1:
field1 field2
101 100
102 200
103 300

table2:
field1 field2
101 111
102 222

如果運行如下語句:
update table1 set field2=(select max(field2) from table2
where table1.field1=table2.field1)
where exists(select field2 from table2
where table1.field1=table2.field1);


update xmstc.student s set
s.city =(
select a1.areaname from xmstc.area a1 where a1.areaid = (
select a2.parentid as id2 from gk.area a2 where a2.areaname = du.city and a2.depth =3
)
) where exists (
select areaname from xmstc.area a3 where a3.city = a3.areaname and a3.depth =3

)
發佈了112 篇原創文章 · 獲贊 1 · 訪問量 7564
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章