大家帮忙看已下SQL语句

vovoon 2006-02-15 03:20:18
' update t_storage set willoutnum=case isnull(willoutnum,0) when 0 then 0 else willoutnum end+'+S_num+
' where cinvgg='''+e_cinvgg.Text+''' and cinvname='''+cmb_cinvname.text+''' and cinvpp='''+
cmb_cinvpp.Text+''' and address='''+cmb_address.Text+''''
什么意思,看不明白
...全文
374 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dandanyiwang 2006-02-15
  • 打赏
  • 举报
回复
询问 when 0 then 0 else willoutnum end 含义

意思就是当字段 willoutnum 的值为空的时候,以0显示,否則就以原值輸出显示.
IFocusYou 2006-02-15
  • 打赏
  • 举报
回复
学习了
vovoon 2006-02-15
  • 打赏
  • 举报
回复
update t_storage set willoutnum=case isnull(willoutnum,0) when 0 then 0 else willoutnum end+'+S_num+
' where cinvgg='''+e_cinvgg.Text+''' and cinvname='''+cmb_cinvname.text+''' and cinvpp='''+
cmb_cinvpp.Text+''' and address='''+cmb_address.Text+'''' 询问 when 0 then 0 else willoutnum end 含义
samson_www 2006-02-15
  • 打赏
  • 举报
回复
反正语句有点累赘,楼上正解,如果上面的end再往后面,就是另外一个意思
-狙击手- 2006-02-15
  • 打赏
  • 举报
回复
'update t_storage set willoutnum=isnull(willoutnum,0)+'+S_num+' where cinvgg='''+e_cinvgg.Text+''' and cinvname='''+cmb_cinvname.text+''' and cinvpp='''+cmb_cinvpp.Text+''' and address='''+cmb_address.Text+''''

---

满足条件记录中的willoutnum为空时更新为0
子陌红尘 2006-02-15
  • 打赏
  • 举报
回复
既然已经用了isnull(),就不需要case ... when ... end了:
---------------------------------------------------------------------------------------------------------------------------------
'update t_storage set willoutnum=isnull(willoutnum,0)+'+S_num+' where cinvgg='''+e_cinvgg.Text+''' and cinvname='''+cmb_cinvname.text+''' and cinvpp='''+cmb_cinvpp.Text+''' and address='''+cmb_address.Text+''''

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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