从数据库php mysql搜索日期范围

时间:2016-05-04 15:33:18

标签: php mysql

从我的表格中,我有一个这样的日期范围:

05/16 / 2016,05 / 17 / 2016,05 /二千零十六分之十八

我的桌子里面有:

-----------------------------------
ID   |   Key   |   Value   
-----------------------------------
10   |   mydt  |   05/14/2016,05/15/2016,05/16/2016,05/17/2016, 05/18/2016,05/19/2016,05/20/2016

我必须搜索我的$ _POST ['date']是否在内部值,以下将不起作用:

SELECT * FROM my_table WHERE key = mydt AND value LIKE '%05/16/2016,05/17/2016,05/18/2016%'

SELECT * FROM my_table WHERE key = mydt AND value IN('05/16/2016','05/17/2016','05/18/2016')

请问如何处理?谢谢你的帮助

1 个答案:

答案 0 :(得分:1)

您可能忘记了orand命令

SELECT * FROM my_table WHERE key = mydt AND value LIKE '%05/16/2016% or LIKE '%05/17/2016%' or LIKE '%05/18/2016%'

试试吧......