mysql 年月日不同字段 如何按照区间筛选
如题 有趣的题 如何快速查询且准确
eg:
id month day
1 5 1
2 5 6
3 6 19
4 7 1
5 7 2
筛选出5月6号-7月1号的id
mysql 年月日不同字段 如何按照区间筛选
如题 有趣的题 如何快速查询且准确
eg:
id month day
1 5 1
2 5 6
3 6 19
4 7 1
5 7 2
筛选出5月6号-7月1号的id
通用开始,中间连续,结束三段union
select id from tbl where month = 5 and day >= 6
union
select id from tbl where month > 5 and month < 7
union
select id from tbl where month = 7 and day <= 1
针对特殊日期
select id from tbl where month = 5 and day >= 6
union
select id from tbl where month = 6
union
select id from tbl where month = 7 and day = 1
5 回答3.2k 阅读✓ 已解决
3 回答3.6k 阅读✓ 已解决
1 回答4k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
2 回答2.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
5 回答1.3k 阅读
mysql有字符串转时间和时间戳的函数 也有将多个字段拼接的函数
拼接下转下格式 再比对区间参数