sql 联表更新
mysql:
SELECT * FROM tablename as a LEFT JOIN xdn_v2.menu as m ON m.old = CONCAT(filed1,str,filed2,field3);
UPDATE tablename1 as a,tablename2.menu as m set a.Menu = m.id WHERE m.old = CONCAT(filed1,str,filed2,field3);
sqlite:
注:字符串使用 || 拼接
update table1 set num1 = (select num2 from table2 where table2.pid=table1.id)
where...
更新多个字段时:
update table1 set num1 = (select num2 from table2 where table2.pid=table1.id), num11 = (select num22 from table2 where table2.pid=table1.id) where...
(2)where时,也一样,比如我就将上面的改一下
update table1 set num = 99 where table1.id=(select pid from table2 where table2.pid=table1.id)
浙公网安备 33010602011771号