close;
sql.Clear;
sql.Add('select case when intType=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' end as inttype1 from test ');
open;
前天看了个帖子,代码如上,我跟着写了个测试代码,inttype是整数型的,怎么运行老是显示CASE查询表达式语法出错,请各位大老赐教,谢谢!
sql.Clear;
sql.Add('select case when intType=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' end as inttype1 from test ');
open;
前天看了个帖子,代码如上,我跟着写了个测试代码,inttype是整数型的,怎么运行老是显示CASE查询表达式语法出错,请各位大老赐教,谢谢!
begin
close;
sql.Clear ;
sql.Add('select case when intType=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' end as inttype1 from test ') ;
open;
end;创建的表的字段 intType 类型是 int
我测试可以的呀
Select iif(IsNull( express ), value1, value2 ) From TableNameiif(IsNull( express ), value1, value2 )
相当于:
If express Is Null Then
Return value1
Else
Return value2
End if
' 我试没有问题,看一下是否你的代码问题'create table tb1(id varchar(20),a int )
insert into tb1 values('1',1)
insert into tb1 values('',1)
insert into tb1(a) values(2)
insert into tb1(a) values(3)select case when a=1 then 'ss' when a=2 then 'aa' end as sss from tb1select * from tb1'1 1
1
NULL 2
(所影响的行数为 3 行)'procedure TForm1.Button1Click(Sender: TObject);
begin
ADOQuery1.close;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select case when a=1 then ''10'' when a=2 then ''20'' end as sss from tb1');
ADOQuery1.open;end;