sql有张表有以下字段

夏日正午阳光 2010-10-23 01:08:53
有张表有以下字段
id mo
1 y
2 n
请用select语句将y显示为yes,n显示为no
id mo
1 yes
2 no
...全文
56 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
如影随从 2010-10-23
  • 打赏
  • 举报
回复
select id,
(case mo when 'y' then 'yes' when 'n' then 'no' else mo end) mo
from tb;
天下如山 2010-10-23
  • 打赏
  • 举报
回复
使用CASE WHEN。
dawugui 2010-10-23
  • 打赏
  • 举报
回复
[Quote=引用楼主 xie99lin 的回复:]
有张表有以下字段
id mo
1 y
2 n
请用select语句将y显示为yes,n显示为no
id mo
1 yes
2 no
[/Quote]
select id , no = 'yes' from tb where no = 'y'
union all
select id , no = 'no' from tb where no = 'n'
「已注销」 2010-10-23
  • 打赏
  • 举报
回复
select id ,case mo when 'y' then 'yes' else 'no' end mo
from tb
SQL2088 2010-10-23
  • 打赏
  • 举报
回复
select id,mo=case when mo='y' then 'yes' else 'no' end 
from tb
xman_78tom 2010-10-23
  • 打赏
  • 举报
回复
select id,
(case mo when 'y' then 'yes' when 'n' then 'no' else mo end) mo
from tb;

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧