jnull Posted June 24, 2011 Share Posted June 24, 2011 I have the following select statement: SELECT * FROM `events` WHERE `Category` = "one" OR `Category` = "two" OR `Category` = "three" AND (`StartDate` BETWEEN "2011-06-30" AND "2011-07-05") ORDER BY `Category` It returns data for all date ranges in the categories specified, which is incorrect. If I only have SELECT * FROM `events` WHERE `StartDate` BETWEEN "2011-06-30" AND "2011-07-05" ORDER BY `Category` it returns nothing which is correct response. Can you give me any idea of what's up with the first select statement? Link to comment https://forums.phpfreaks.com/topic/240314-select-between-dates/ Share on other sites More sharing options...
AMcHarg Posted June 24, 2011 Share Posted June 24, 2011 Try this: SELECT * FROM `events` WHERE (`Category` = "one" OR `Category` = "two" OR `Category` = "three") AND (`StartDate` BETWEEN "2011-06-30" AND "2011-07-05") ORDER BY `Category` Link to comment https://forums.phpfreaks.com/topic/240314-select-between-dates/#findComment-1234380 Share on other sites More sharing options...
jnull Posted June 24, 2011 Author Share Posted June 24, 2011 Thank you ... just perfect! Link to comment https://forums.phpfreaks.com/topic/240314-select-between-dates/#findComment-1234456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.