Mysql常用表达式

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

一、IF语句

	SELECT name,IF(age=1,"男","女") AS ages,address FROM user;
或者
	SELECT 
		CASE (SELECT age FROM user WHERE id=110) 
    			WHEN 1 THEN '男'
    			WHEN 2 THEN '女' 
    			ELSE '未知' 
		END
	AS ages

二、非空

	SELECT name,ages,address FROM user WHERE name IS NOT NULL;

转载于:https://my.oschina.net/yuantangxi/blog/2993613

你可能感兴趣的:(Mysql常用表达式)