IF语句:IF(expr1,expr2,expr3)
若expr1 == TRUE, 则:返回值为 expr2;
若expr1 == FALSE,则:返回值为 expr3;
示例:
select if(sva=1,"男","女") as ssva from taname where id = ‘111‘;
CASE WHEN语句
作为表达式的 IF ,也可使用 CASE WHEN 来实现
SELECT
CASE sva WHEN 1 THEN "男" ELSE "女" END
AS ssva FROM taname WHERE id = ‘1‘;