好像不能这样写:你按如下格式改一下试试: SELECT * CASE state WHEN 'CA' THEN 'California' WHEN 'KS' THEN 'Kansas' WHEN 'TN' THEN 'Tennessee' WHEN 'OR' THEN 'Oregon' WHEN 'MI' THEN 'Michigan' WHEN 'IN' THEN 'Indiana' WHEN 'MD' THEN 'Maryland' WHEN 'UT' THEN 'Utah' END FROM table
select case when refuse=1 then 'yes' else 'no' end AS<-----/*尝试加AS*/ temprefuse from userlog
我的语句在SQLPlus中调试已经可以了。 1。select case when refuse=1 then 'yes' else 'no' end temprefuse from userlog 2。select case when refuse=1 then 100 else 101 end temprefuse from userlog 两句都可以但是当用ADOQuery执行时候会弹出CPU什么错误来。 TempSQL:='select case when refuse=1 then ''yes'' else ''no'' end temprefuse from userlog'; With TempQuery do begin Close; SQL.Clear; SQL.Add(TempSQL); Open;//此处出现CPU什么东东错误了。但是如果把上方2。的SQL传递进去可以返回数据 end;
SELECT *
CASE state
WHEN 'CA' THEN 'California'
WHEN 'KS' THEN 'Kansas'
WHEN 'TN' THEN 'Tennessee'
WHEN 'OR' THEN 'Oregon'
WHEN 'MI' THEN 'Michigan'
WHEN 'IN' THEN 'Indiana'
WHEN 'MD' THEN 'Maryland'
WHEN 'UT' THEN 'Utah'
END
FROM table
temprefuse from userlog
1。select case when refuse=1 then 'yes' else 'no' end temprefuse from userlog
2。select case when refuse=1 then 100 else 101 end temprefuse from userlog
两句都可以但是当用ADOQuery执行时候会弹出CPU什么错误来。
TempSQL:='select case when refuse=1 then ''yes'' else ''no'' end temprefuse from userlog';
With TempQuery do
begin
Close;
SQL.Clear;
SQL.Add(TempSQL);
Open;//此处出现CPU什么东东错误了。但是如果把上方2。的SQL传递进去可以返回数据
end;