用户根据日期搜索数据
select * from employees where hiredate BETWEEN STR_TO_DATE(‘1998-3‘,‘%Y-%c-%d‘) and STR_TO_DATE(‘1999-2‘,‘%Y-%c-%d‘)
if的常用用法
select last_name,commission_pct, IF( commission_pct is NULL,‘幸苦了‘,‘加油干‘) 备注 from employees
case when 的常用用法(swicth)
SELECT
NAME ‘英雄‘,
CASE NAME
WHEN ‘德莱文‘ THEN
‘斧子‘
WHEN ‘德玛西亚-盖伦‘ THEN
‘大宝剑‘
WHEN ‘暗夜猎手-VN‘ THEN
‘弩‘
ELSE
‘无‘
END ‘装备‘
FROM
user_info;
case when 的常用用法(if else if ... else)
SELECT
NAME ‘英雄‘,
age ‘年龄‘,
CASE
WHEN age < 18 THEN
‘少年‘
WHEN age < 30 THEN
‘青年‘
WHEN age >= 30
AND age < 50 THEN
‘中年‘
ELSE
‘老年‘
END ‘状态‘
FROM
user_info;