(编辑:jimmy 日期: 2024/12/27 浏览:2)
一、单表查询—>更新
UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]
二、多表联合查询—>更新
UPDATE a INNER JOIN (SELECT yy FROM b) c ON a.id = c.id SET a.xx = c.yy [WHERE Clause]
例子:
tableex_copy1表
tablein_copy1表
查询SQL
SELECT * FROM tableex_copy1 a LEFT JOIN (SELECT * FROM tablein_copy1) b ON a.BID = b.AID WHERE b.ASEX = '女'
update SQL
UPDATE #SELECT * FROM tableex_copy1 a LEFT JOIN (SELECT * FROM tablein_copy1) b ON a.BID = b.AID SET a.CESHI = '6666' WHERE b.ASEX = '女'
更新之后的tableex_copy1表
总结