查询某天的数据
查询今天to_days(now())
sql
EXPLAIN SELECT
*
FROM
member_schedule_relation msr
LEFT JOIN `schedule` s ON s.id = msr.schedule_id
LEFT JOIN member m ON m.id = msr.member_id
WHERE
msr.member_id = 1
AND s.deleted = 0
AND s.start_time <= '2020-4-3' AND s.end_time >= '2020-4-2'
ORDER BY
s.start_time
sql
SELECT
*
FROM
article
WHERE
to_days( create_time ) = to_days( '2018-09-10' )
查询某天到某天的数据
sql
SELECT
*
FROM
article
WHERE
create_time BETWEEN '2019-4-1'
AND '2019-4-7'
查询某个月的数据
sql
SELECT
*
FROM
article
WHERE
date_format( create_time, '%Y-%m' ) = '2019-04'
查询某年的数据
SELECT
*
FROM
article
WHERE
date_format( create_time, '%Y' ) = '2018'