user44321 user44321 - 7 months ago 16
SQL Question

Search range of date from database php mysql

Form my form i have a range of date like this :

05/16/2016,05/17/2016,05/18/2016

Inside my table i have :

-----------------------------------
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


I have to search if my $_POST['date'] is inside value, following will not working :

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')


How to handle this please ? thanks for your help

Answer

May be you have forgotten or or and command

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

Try it....