批量更新

有如下两个表:
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章