MySQL IF CASE 例子

记录一下,方便日后查看

SELECT USER_CODE AS '用户编码',
IF(USER_STATE = 1, '正常', '冻结') AS '用户状态',
(
	CASE USER_TYPE
	WHEN 1 THEN
		'用户'
	WHEN 2 THEN
		'商家'
        WHEN 3 THEN
		'自营'
	ELSE
		'未知'
	END 
) AS '用户类型'
FROM 
	USER_INFO LIMIT 10;
posted @ 2020-07-03 10:14  klvchen  阅读(181)  评论(0编辑  收藏  举报