I have a single mysql table called prices storing dates from and to like so:
id from to price
1 2013-11-25 2014-01-08 55
the user selects a month and a year and i want it to show all results that either are from or to that month so if the user selected either november 2013, december 2013 or january 2014 it would include the above row.
id from to price
2 2013-10-25 2013-11-07 100
and if they selected either october or november 2013 it would show the above row because it starts in october and ends november.
i have tried
SELECT * FROM `prices`
WHERE MONTH(prices.from)<={$_SESSION['month']}
AND MONTH(prices.to)>={$_SESSION['month']}
AND YEAR(prices.to)={$_SESSION['year']}
ORDER BY prices.from ASC
which doesn't work i'm not sure how this can be done
WHERE xxx BETWEEN xxx AND xxx