你的sql语句写的不对,应该在where子句中增加限制才对 update t_table a set (f1,f2,f3)=(select f1,f2,f3 from testz b ) where a.id=b.id
...你这个写法明显语法就错误了update t_table a set (f1, f2, f3) = (select f1, f2, f3 from testz b where a.id = b.id) where exists (select 1 from testz b where a.id = b.id)
...你这个写法明显语法就错误了update t_table a set (f1, f2, f3) = (select f1, f2, f3 from testz b where a.id = b.id) where exists (select 1 from testz b where a.id = b.id) 你的回复是正确的,怎么理解这个事情?
...你这个写法明显语法就错误了update t_table a set (f1, f2, f3) = (select f1, f2, f3 from testz b where a.id = b.id) where exists (select 1 from testz b where a.id = b.id) 你的回复是正确的,怎么理解这个事情?没有带where条件,那肯定是全表更新了。 (select f1, f2, f3 from testz b where a.id = b.id) 这个只是代表能不能更新到值,找不到肯定就会置空。 跟表需要更新多少数据是没有直接关系的。
2楼比1楼好的地方在于"注意空值的影响" 通常关联update、2楼那样是可以的
select f1, f2, f3 from testz b where a.id = b.id这句话有没有返回多行的可能......
楼上是对的,要在外层加个where exists的 update t_table a set (f1, f2, f3) = (select f1, f2, f3 from testz b where a.id = b.id) where exists (select 1 from testz b where a.id = b.id)
因为你的(select f1,f2,f3 from testz b where a.id=b.id)这个值为空,为什么为空,因为你条件里只有个b表,而a表在上面,在这里没有写。在from 后面加个“a,”就可以了。
update t_table a set (f1,f2,f3)=(select f1,f2,f3 from testz b )
where a.id=b.id
...你这个写法明显语法就错误了update t_table a
set (f1, f2, f3) =
(select f1, f2, f3 from testz b where a.id = b.id)
where exists (select 1 from testz b where a.id = b.id)
...你这个写法明显语法就错误了update t_table a
set (f1, f2, f3) =
(select f1, f2, f3 from testz b where a.id = b.id)
where exists (select 1 from testz b where a.id = b.id)
你的回复是正确的,怎么理解这个事情?
...你这个写法明显语法就错误了update t_table a
set (f1, f2, f3) =
(select f1, f2, f3 from testz b where a.id = b.id)
where exists (select 1 from testz b where a.id = b.id)
你的回复是正确的,怎么理解这个事情?没有带where条件,那肯定是全表更新了。
(select f1, f2, f3 from testz b where a.id = b.id)
这个只是代表能不能更新到值,找不到肯定就会置空。
跟表需要更新多少数据是没有直接关系的。
通常关联update、2楼那样是可以的
update t_table a
set (f1, f2, f3) =
(select f1, f2, f3 from testz b where a.id = b.id)
where exists (select 1 from testz b where a.id = b.id)