mysql中寫法:
表1:name 、tell 、id、score
表2:name、tell、ryid、subject
需求:将表2的tell的值更新給表1的tell
update 表1 t1,表2 t2 set t1.tell = t2.tell where t1.id=t2.ryid;--更新單個值
update 表1 t1,表2 t2 set t1.tell = t2.tell,t1.name=t2.name where t1.id = t2.ryid;--更新多個值,用,(逗号)隔開;
oracle中寫法:
update 表1 t1 set t1.tell = (select t2.tell from 表2 where t1.id = t2.ryid) where exists (select 1 from 表2 t2 where t1.id = t2.ryid); --更新單個值
update 表1 t1 set t1.tell,t1.name = (select t2.tell,t2.name from 表2 where t1.id = t2.ryid) where exists (select 1 from 表2 t2 where t1.id = t2.ryid); --更新多個值
總結:mysql中更新字段值和oracle中更新字段值的寫法不一樣;oracle更繁瑣;