请问,这个SQL语句怎么写?(50分)

  • 主题发起人 主题发起人 天真
  • 开始时间 开始时间

天真

Unregistered / Unconfirmed
GUEST, unregistred user!
表A
ID A B
1 2 0
2 0 2

结果
表A
ID A B
1 1 0
2 0 1
用UPDATE语句实现,该怎么实现,我用CASE语句写不出来!HELP ME!
 
没有搞明白。。。
 
如果字段A大于0则A-1,如果B字段大于0,则B-1
 
说清楚点
 
update 表一 set A=A-1 where a>0
update 表一 set b=b-1 where b>0
 
update A set A="1",B="0"
where id=1;
update A set A="0",B="1"
where id=2;
 
同意lkpc说写
 
同上。http://www.delphibbs.com/delphibbs/dispq.asp?lid=958559
 
各位大哥:我是想用一句SQL实现,其实这个更新与ID无关!
 
update A set A=A-1,B=B-1
where id=1;
update A set A=A-1,B=B-1
where id=2;
这样好了[:)]
 
試一下這個:
update table1 set a=case when a>0 then a-1
else a
end,
b=case when b>0 then b-1
else b
end
 
呵,原来是这样,我位置放错了,谢谢~0~
 
接受答案了.
 
后退
顶部