高手请进,急急。。。。。多谢多谢。。。

kinglccs 2003-10-22 08:57:45
为什么我的SQL2000说isempty()是一个无法识别的函数呢?
另外我想在SELECT里嵌套IF语句,如何写这个语句呢?
table A (a,b,c)
table B (e,f,g)
table C (h,i,j)

我用select into 语句去读 A.a,如果a为空或者为0,,我就把这列付值为B.e,否则我就赋值C.h

...全文
39 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
newdongkui 2003-10-23
  • 打赏
  • 举报
回复
今天有空上来一看
select ( case when isnull(A.a,0) <> 0 then A.a
when isnull(A.a,0) = 0 and isnull(B.e,0) <> 0 then B.e
else C.h end) as xxx
from A,B,C
where your condition
发现,我少写了一个end,呵呵,对不住啦.
welyngj 2003-10-22
  • 打赏
  • 举报
回复
不对:
select a.a1,a.a2,(case when a.a3 is not null then c.c2
else b.b2 end) as xxx
into abc
from a,b,c
welyngj 2003-10-22
  • 打赏
  • 举报
回复
select a.a1,a.a2,(case when a.a3 is null then c.c2
when a.a3 is not null then b.b2 end) as xxx
into abc
from a,b,c
welyngj 2003-10-22
  • 打赏
  • 举报
回复
select a.a1,a.a2,(case when isnull(a.a3,0)<>0 then c.c2
when isnull(a.a3,0)==0 then b.b2 end) as xxx
into abc
form a,b,c
kinglccs 2003-10-22
  • 打赏
  • 举报
回复
table: a (a1,a2,a3)
table: b (b1,b2,b3)
talbe: c (c1,c2,c3)
在a里有很多数据,我全部需要,但是对我有用的只有几列,其中a3是一个判断条件,如果a3是一个空值,我就把这列用b.b2赋值,如果他不是空的,我就用c.c2赋值
select a.a1,a.a2,(case when isnull(a.a3,0)<>0 then c.c2
when isnull(a.a3,0)==0 then b.b2) as xxx
into abc
form a,b,c
然后提示我说:')' 附近有语法错误。
kinglccs 2003-10-22
  • 打赏
  • 举报
回复
谢谢。我用了你的语句,但是提示我")有语法问题"
newdongkui 2003-10-22
  • 打赏
  • 举报
回复
select ( case when isnull(A.a,0) <> 0 then A.a
when isnull(A.a,0) = 0 and isnull(B.e,0) <> 0 then B.e
else C.h ) as xxx
from A,B,C
where your condition

zarge 2003-10-22
  • 打赏
  • 举报
回复
isempty()不是TSQL的函数

34,874

社区成员

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

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