IF表达式
SELECT IF(sva=1,"男","女") AS s FROM table_name WHERE sva != '';
CASE WHEN
SELECT CASE sva WHEN 1 THEN '男' ELSE '女'
END AS s
FROM table_name WHERE sva != '';
IFNULL(expr1,expr2)
假如expr1 不为 NULL,则 IFNULL() 的返回值为 expr1; 否则其返回值为 expr2。IFNULL()的返回值是数字或是字符串,具体情况取决于其所使用的语境
select ifnull((SELECT if(service_status='COMPLETED',TRUE,FALSE) as allow_show from es_as_order WHERE order_sn ='2226067809608867869'), 0) as allow_show;