最近5天内过生日的成员

SELECT * 
from `member_info` 
where (CAST(CONCAT(YEAR(CURRENT_DATE()),DATE_FORMAT(`birthday`,"-%m-%d")) AS DATE) - CURRENT_DATE()) BETWEEN 0 AND 5 
ORDER BY DAYOFMONTH(`birthday`) ,MONTH(`birthday`)

CAST( a AS TYPE) 将a强制转换为TYPE类型的数据

CONCAT(a,b)将字符串a,b连接成为字符串ab

DATAFORMAT(date,format) 将date转换成format格式


你可能感兴趣的:(MYSQL,MYSQL)