这样的SQL语句有啥问题?

arfayr 2003-08-07 10:34:23
Update Table1 set Field1=(select New from table2,table1 where table2.old=table1.field1)

我的意思是把table1.field1的值按照table2的新旧对应关系更新
...全文
34 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
suleen 2003-08-08
  • 打赏
  • 举报
回复
update table1 set table1.field1 = (select table2.new from table2
where table2.old = table1.field1)
panyee 2003-08-08
  • 打赏
  • 举报
回复
new字段没有指定是哪个表的
beckhambobo 2003-08-08
  • 打赏
  • 举报
回复
Update Table1 a set Field1=(select New from table2 b where b.old=a.field1)
kerisyml 2003-08-08
  • 打赏
  • 举报
回复
update table1 set field1 = (select b.new from table1 a,table2 b
where b.old = a.field1)
tcmis 2003-08-08
  • 打赏
  • 举报
回复
Update Table1 a set Field1=(select New from table2 b where b.old=a.field1) where
b.old=a.field1
sqllearner 2003-08-08
  • 打赏
  • 举报
回复
Update Table1 set Field1=(select New from table2,table1 where table2.old=table1.field1)

根据错误信息判断是子查询返回了多个值给table1的field1,如果多个new值都相同可以在子查询的
select和new中间加个distinct。如多个new值不相等则具体用哪个值替换要另加条件!!!

arfayr 2003-08-08
  • 打赏
  • 举报
回复
应该不是这些原因,我全部写全了也不行。估计()里面的Select语句应该用左连接

返回错误信息是
单条语句返回了多条结果

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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