update t1 set a= t2.x from t1,t2 where t1.b=t2.b and t2.c= 44这样的sqlserver语句如何在oracel中写?update t1 set a= (select x from t2 where t1.b=b and c=44) 这样写法为何不对?
能不能当两表数据相匹配时,进行更新,当前子查询没有查到时不更新,像sqlserver update t1 set a= t2.x from t1,t2 where t1.b=t2.b and t2.c= 44
select x from t2 where t1.b=b and c=44 这句不对 这个语句里没有T1表,WHERE里怎么会对
能不能当两表数据相匹配时,进行更新,当前子查询没有查到时不更新,像sqlserver update t1 set a= t2.x from t1,t2 where t1.b=t2.b and t2.c= 44
update t1 T set a = (select S.x from t2 S where T.b = S.b and S.c = '44') where exists (select 1 from t2 S where T.b = S.b and S.c = '44')菜鸟也来凑下热闹
顶上面的 update t1 T set a = (select distinct S.x from t2 S where T.b = S.b and S.c = '44') where exists (select 1 from t2 S where T.b = S.b and S.c = '44') 加个distinct,防止返回多条记录除此之外还有没有别的方法了, 如果要更新一个以上的字段,这个方法好像就不好使了...请高人指点 关注中......
update t1 set a=(select max(x) from t2 where t1.b=b)
where a.b in (select t2.b from t2 where t2.c=44)
如果子查询返回的结果多于一条记录,那更新语句将会出错?如果不能保证结果只是一条记录,那是不是还要套一个子查询和rownum来保证只有一条记录?
update t1 set a= t2.x
from t1,t2
where t1.b=t2.b and t2.c= 44
这句不对
这个语句里没有T1表,WHERE里怎么会对
update t1 set a= t2.x
from t1,t2
where t1.b=t2.b and t2.c= 44
update t1 T
set a = (select S.x
from t2 S
where T.b = S.b
and S.c = '44')
where exists (select 1
from t2 S
where T.b = S.b
and S.c = '44')菜鸟也来凑下热闹
update t1 T
set a = (select distinct S.x
from t2 S
where T.b = S.b
and S.c = '44')
where exists (select 1
from t2 S
where T.b = S.b
and S.c = '44')
加个distinct,防止返回多条记录除此之外还有没有别的方法了,
如果要更新一个以上的字段,这个方法好像就不好使了...请高人指点
关注中......