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更繁琐;