码迷,mamicode.com
首页 > 数据库 > 详细

SQL case语句

时间:2016-09-29 18:04:39      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

示例:

select
    id,
    name,
    case user_role
when 0 then
    "管理员"
when 1 then
    "未注册用户"
when 2 then
    "注册用户"
else
    concat("未知值:", user_role)
end 
“角色”
from user

 

SQL case语句

标签:

原文地址:http://www.cnblogs.com/z-sm/p/5920536.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!