如何通过SQL语句根据查询出来的内容判断输出自己想要看到的内容

例如:sql语句查询出店类型是数值,如何在SQL语句中根据查询出来的数值进行判断,从而输出中文显示。
想把店类型的查询结果直接显示为为某某店

第1个回答  2015-04-03
select a.ID,a.name,sex,b.ID,b.name,old from A full join B on a.ID=b,ID order by a.ID;
按下列方式试试。
select a.ID,a.name,sex,b.ID,b.name,old from A full join B on a.ID=b,ID
where (a.name is null and a.sex is null and b.name is not null) or
(a.name is not null and a.sex is not null and b.name is null)
order by a.ID;本回答被网友采纳
第2个回答  2015-04-03
select switch([店类型]="0102","店1",[店类型]="0103","店2"……) as 店名称,* from 你的表
switch后面可以加多个追问

再帮忙看看,我这样些表达式缺失。
select sl.shoppeid 店代码,er.SQUARECOMPANYNAME 店名称,switch(er.COMPANYORGANISEID="0102","卖断专卖店",er.COMPANYORGANISEID="0101","联销商场") as 店类型

追答

select [sl].[shoppeid] as 店代码,[er].[SQUARECOMPANYNAME] as 店名称,switch([er].[COMPANYORGANISEID]="0102","卖断专卖店",[er].[COMPANYORGANISEID]="0101","联销商场") as 店类型 from sl,er

本回答被提问者采纳
相似回答