查询某时间范围内的数据SQL语句MySQL数据库查询时间段的两种⽅法
1.BETWEEN
sql语句查询不包含SELECT id FROM m_question WHERE cratedate BETWEEN
TO_DAYS(‘2019-05-3100:00:00’) and TO_DAYS(‘2019-06-0100:00:00’) ORDER BY id DESC
2. > < 符号查询
SELECT id FROM m_question WHERE cratedate BETWEEN
‘2019-05-3100:00:00’ and ‘2019-06-0114:59:59’ ORDER BY id DESC
或者
SELECT id FROM m_question WHERE cratedate >
‘2019-05-3100:00:00’ and cratedate < ‘2019-06-0114:59:59’ ORDER BY id DESC
注意:
between and 包含时间界限,这就相当于>= <=,⽽> <;不包含。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论