之前看到老徐写过的关于Case When 解决简单的"是"与"否"的解决方法,试用了一下.效果很好.就想如果不用存储过程(比如Access数据库是不能用存储过程的),下面给出方法.
一.不用存储过程:
select a.softName,a.softId,a.SoftSize,a.softDetails,a.IsElite,b.ClassName,case a.IsElite when 1 then '是' when 0 then '否' End as IsElite1 from soft_info as a join soft_Class as b on a.ClassId=b.ClassId where a.IsAuthorized = 1 and a.SoftName Like '%" + TxtQueryKeyWords.Text + "%'

二.用存储过程:
CREATE PROCEDURE  proselect_softinfo  AS
select a.softName,a.softId,a.SoftSize,a.softDetails,a.IsElite,b.ClassName,
case  a.IsElite
when 1 then '是'
when 0 then '否'
end as IsElite1
from soft_info as a join soft_Class as b on a.ClassId=b.ClassId
where IsAuthorized = 1
GO

如果是多个的话:
CREATE procedure proselect_articlebyclass
(
@ClassID as int
)
as
select a.ArticleTitle,
a.ArticleId,
a.addDate,
a.UserName,
a.IsAuthorized,
a.IsElite,
b.ClassName,
case a.IsAuthorized
when 1 then '是'
when 0 then '否'
end as IsAuthorized1,
case a.IsElite
when 1 then '是'
when 0 then '否'
End as IsElite1
from softArticle_info as a join Soft_Class as b
on a.ClassId=b.ClassId where a.ClassID=@ClassID order by a.AddDate Desc
GO