mysql 年月日不同字段 如何按照區(qū)間篩選如題 有趣的題 如何快速查詢且準(zhǔn)確eg: id month day
1 5 1
2 5 6
3 6 19
4 7 1
5 7 2篩選出5月6號(hào)-7月1號(hào)的id
2 回答

浮云間
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超4個(gè)贊
mysql有字符串轉(zhuǎn)時(shí)間和時(shí)間戳的函數(shù) 也有將多個(gè)字段拼接的函數(shù)
拼接下轉(zhuǎn)下格式 再比對(duì)區(qū)間參數(shù)

至尊寶的傳說(shuō)
TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊
通用開(kāi)始,中間連續(xù),結(jié)束三段union
select id from tbl where month = 5 and day >= 6union select id from tbl where month > 5 and month < 7union select id from tbl where month = 7 and day <= 1
針對(duì)特殊日期
select id from tbl where month = 5 and day >= 6union select id from tbl where month = 6union select id from tbl where month = 7 and day = 1
- 2 回答
- 0 關(guān)注
- 790 瀏覽
添加回答
舉報(bào)
0/150
提交
取消