你的update b set b.name=a.name from t1 a, t2 b where a.code=b.code and a.name='bbb'这句效果就是update t2 set name='bbb' from t1 a, t2 b where a.code=b.code and a.name='bbb' 不信你可以试试
--为了减少误会改为如下: --sqlserver 中的写法 update b set b.name=a.name from t1 a, t2 b where a.code=b.code and a.name<>'ccc' ; --请问oracle中等效的sql语句如何写
update t2 set t2.name = ( select t1.name from t1 where t1.code = t2.code and t1.name <> 'ccc') 这一句在sql server与oracle都能执行. 在sql server中,t2后不能带别名(我这里是sql server7).
set b.name=a.name
from t1 a, t2 b
where a.code=b.code and a.name='bbb'这句效果就是update t2 set name='bbb'
from t1 a, t2 b
where a.code=b.code and a.name='bbb'
不信你可以试试
--sqlserver 中的写法
update b
set b.name=a.name
from t1 a, t2 b
where a.code=b.code and a.name<>'ccc'
;
--请问oracle中等效的sql语句如何写
select t1.name
from t1
where t1.code = t2.code
and t1.name <> 'ccc')
这一句在sql server与oracle都能执行.
在sql server中,t2后不能带别名(我这里是sql server7).
面,应该在外面而且还要加一些条件。