菜鸟求助SQL语句!

new_one_one 2011-05-13 06:02:51
跨表更新:
A表:id,name
B表:id,number,name

实现目标:按照两表name相同的字段,把A表的id字段值更新到B表的number字段。
我的SQL语句:
update B set number=A.id from A where rtrim(A.name)=rtrim(B.name)
在TOAD下运行错误,提示:ORA-00933: SQL command not properly ended

求达人指正!!!

不胜感激!!!
...全文
116 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
So_CooL 2011-05-14
  • 打赏
  • 举报
回复
update c
set b.number = c.id from A c inner join B on c.name = b.name
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 xyctc 的回复:]
SQL code
update B set number=(select id from a where rtrim(A.name)=rtrim(B.name)) where exist
(
select 1 from a where rtrim(A.name)=rtrim(B.name))
)

貌似oracle环境下,mssql环境下UPDATE没问题的
转版
[/Quote]


他是oracle,不是SQL,語法上有點區別,你到oracle版問問吧
他是
Billy 2011-05-14
  • 打赏
  • 举报
回复

update B set number=(select id from a where rtrim(A.name)=rtrim(B.name)) where exist
(
select 1 from a where rtrim(A.name)=rtrim(B.name))
)

貌似oracle环境下,mssql环境下UPDATE没问题的
转版
new_one_one 2011-05-13
  • 打赏
  • 举报
回复
不得行啊 不得行
qgqch2008 2011-05-13
  • 打赏
  • 举报
回复
update set B.number = A.id from A join B on rtrim(A.name)=rtrim(B.name)
new_one_one 2011-05-13
  • 打赏
  • 举报
回复
还是提示错误:ORA-00933: SQL command not properly ended

提示错误在 from 处

[Quote=引用 3 楼 ssp2009 的回复:]
update B set B.number=A.id from B,A where rtrim(A.name)=rtrim(B.name)
[/Quote]
new_one_one 2011-05-13
  • 打赏
  • 举报
回复
错误依旧
[Quote=引用 2 楼 forfumm 的回复:]
SQL code
UDPATE B SET number=A.id FROM A, B WHERE RTRIM(A.name)=RTRIM(B.name)
[/Quote]
快溜 2011-05-13
  • 打赏
  • 举报
回复
update B set B.number=A.id from B,A where rtrim(A.name)=rtrim(B.name)
ForFumm 2011-05-13
  • 打赏
  • 举报
回复
UDPATE B SET number=A.id FROM A, B WHERE RTRIM(A.name)=RTRIM(B.name)
jiao3630 2011-05-13
  • 打赏
  • 举报
回复
貌似么啥错误
下班回家了

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧