Jump to content

query with two IN()'s


dadamssg87

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.