dadamssg87 Posted December 10, 2011 Share Posted December 10, 2011 Table structure id(int)date(date)group(int)deleted(timestamp)rate(decimal(6,2)) 12011-12-1420000-00-00 00:00:0099.99 22012-01-1920000-00-00 00:00:00149.99 32012-07-2830000-00-00 00:00:00249.99 42012-03-0350000-00-00 00:00:0049.99 I'm receiving an array of group id's and dates. I'm imploding them and separating them by commas to form strings. I'm trying to write a query that only pulls up rows that have groups that are in the group string and dates that in the dates string. <?php $groups[] = 2; $groups[] = 5; $dates[] = "2011-12-14"; $dates[] = "2011-12-15"; $dates[] = "2011-12-16"; $dates[] = "2012-03-03"; $groups = implode(',', $groups); $dates = implode(',',$dates); $query = "SELECT * FROM `Exceptions` where `group` in($groups) AND `date` in($dates) AND deleted = '0000-00-00 00:00:00'"; ?> This query results in zero rows. I'm expecting to get get row 1 and row 4. Anybody know what i'm doing wrong? Link to comment https://forums.phpfreaks.com/topic/252894-query-with-two-ins/ Share on other sites More sharing options...
Pikachu2000 Posted December 10, 2011 Share Posted December 10, 2011 Your date values in $dates need to be implode()d so the values end up in quotes . . . Link to comment https://forums.phpfreaks.com/topic/252894-query-with-two-ins/#findComment-1296575 Share on other sites More sharing options...
dadamssg87 Posted December 10, 2011 Author Share Posted December 10, 2011 ahh yeah that was it..thanks! Link to comment https://forums.phpfreaks.com/topic/252894-query-with-two-ins/#findComment-1296584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.