SQL语句用法: select case语句块后面能否加where 条件?
展开全部
when。。。。。。。。。then。。。。。。。 when就相当於where
create table table_3(a varchar ,b varchar)
insert into table_3 values('1','2')
insert into table_3 values('1','3')
insert into table_3 values('2','2')
select * from table_3
---when语句中的类型和else必须一致
select (case a when '1' then'123'
when '2' then '456'
else 0
end ) as aa ,a,b from table_3
select case when a=1 then '中文'
when a=2 then '英文'
else '过问' end
from table_3
create table table_3(a varchar ,b varchar)
insert into table_3 values('1','2')
insert into table_3 values('1','3')
insert into table_3 values('2','2')
select * from table_3
---when语句中的类型和else必须一致
select (case a when '1' then'123'
when '2' then '456'
else 0
end ) as aa ,a,b from table_3
select case when a=1 then '中文'
when a=2 then '英文'
else '过问' end
from table_3
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询