请教修改语句

zzxiaoma 2006-08-02 08:58:43
在oracle中
表 a
dscardno money
10001 5
10003 6
10004 3
表 b
cardno money
10001 1
10002 1
10003 1
10004 1
结果是:
表 b
cardno money
10001 5
10002 1
10003 6
10004 3
...全文
305 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzxiaoma 2006-08-10
  • 打赏
  • 举报
回复
为什么都说可以呢,我用的是oracle9i,sql tools工具
gw_delphi 2006-08-10
  • 打赏
  • 举报
回复
update b set b.money=(select a.money from a where a.dscardno = b.dscardno)
where exists (select 1 from a where a.dscardno = b.cardno);

update b set b.money=(select a.money from a where a.dscardno = b.dscardno)
where b.dscardno in (select a.dscardno from a);

update b set b.money=nvl((select a.money from a where a.dscardno=b.cardno),money);
snowy_howe 2006-08-10
  • 打赏
  • 举报
回复
我是用oracle 客户端的sql*plus工具连接数据库的,不知道你说的SQL TOOLS工具又是什么呢?
请多提供一些错误情况,大家帮你分析问题好吗?
如果该TOOLS工具不提供错误信息,那么我建议你抛弃它,因为不够友好~~~
如果提供错误信息,请原封不动的拷贝到CSDN上来,好吗?
caoqizi 2006-08-09
  • 打赏
  • 举报
回复
呵呵,如果不想用snowy_howe(天下有雪) 兄的,用我这个试试,其实他那个应该不错的,我这个比较笨了点。
update b set money=decode((select money from a where a.dscardno=b.cardno),null,money,(select money from a where a.dscardno=b.cardno))
zzxiaoma 2006-08-09
  • 打赏
  • 举报
回复
你难道真的测试过了吗????难道就没有问题吗
不能凭经验阿
你可以试试就知道后果了
snowy_howe 2006-08-03
  • 打赏
  • 举报
回复
SQL> select * from a;

DSCARDNO MONEY
---------- ----------
10001 5
10003 6
10004 3

SQL> select * from b;

CARDNO MONEY
---------- ----------
10001 1
10002 1
10003 1
10004 1

SQL> update b set money=(select money from a where a.dscardno=b.cardno)
2 where exists (select 1 from a where a.dscardno=b.cardno);

已更新3行。

SQL> select * from b;

CARDNO MONEY
---------- ----------
10001 5
10002 1
10003 6
10004 3

SQL>

用的zmgowin(hermit)的语句,请问哪里不行了?
snowy_howe 2006-08-03
  • 打赏
  • 举报
回复
上面几个人提供的SQL语句到底发生什么错误?能贴出来吗?
也方便别人帮你分析,没有互动的话心有余而力不足啊~~

说实话,简单的一个“不行”很让人心冷。
zzxiaoma 2006-08-02
  • 打赏
  • 举报
回复
真的没有高手吗??
这个应该很简单的把
我会在MSSQL里用,但在oracle中就不能用了
zzxiaoma 2006-08-02
  • 打赏
  • 举报
回复
不行
lwk_hlj 2006-08-02
  • 打赏
  • 举报
回复
udpate b set money=(select money from a where a.dscorno=b.codno)
where b.cardno in (select dscardno from a)
zzxiaoma 2006-08-02
  • 打赏
  • 举报
回复
不行
sxykje 2006-08-02
  • 打赏
  • 举报
回复
555555555
更新不是查询
zmgowin 2006-08-02
  • 打赏
  • 举报
回复
update b set money=(select money from a where a.dscardno=b.cardno)
where exists (select 1 from a where a.dscardno=b.cardno);

update b set money=nvl((select money from a where a.dscardno=b.cardno),money);
sxykje 2006-08-02
  • 打赏
  • 举报
回复
select no,max(money)
from (select dscardno no,money from a
union all
select cardno no ,money from b) t
group by no
不好意思
漏了关键字了
sxykje 2006-08-02
  • 打赏
  • 举报
回复
select no,money
from (select dscardno no,money from a
union all
select cardno no ,money from b) t
group by no

17,377

社区成员

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

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