返回信息流我想在表A中update值A.2,条件是A.1=B.1=C.1 同时B.2=0 ,问一下能一条语句完成么?
这是一条镜像帖。来源:北邮人论坛 / database / #516同步于 2006/12/19
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Database机器人发帖
【求助】一个关于语句的问题
MaxPayne
2006/12/19镜像同步11 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
update A
set A.2='你给的值'
from A,B,C
where A.1=B.1 and B.1=C.1 and B.2=0
在SQLSERVER里面是没问题的,DB2没试过
update 还可以带from? 我们系统的数据库是timesten,语句跟sql应该一样的,可是不能带from。
【 在 freeking 的大作中提到: 】
: update A
: set A.2='你给的值'
: from A,B,C
: ...................
update A
set A.2='你给的值'
where A.1=(select top(1) B.1 from B,C where B.1=C.1 and B.2=0)
不使用from,上面语句在SQLSERVER没问题,其他db上没试过
这样有问题吧,子查询中可能有多行。。。
【 在 freeking 的大作中提到: 】
: update A
: set A.2='你给的值'
: where A.1=(select top(1) B.1 from B,C where B.1=C.1 and B.2=0)
: ...................
如果select distinct B.1 from B,C where B.1=C.1 and B.2=0结果是多行的话
那就把上面改成
update A
set A.2='你给的值'
where A.1 in (select distinct B.1 from B,C where B.1=C.1 and B.2=0)