tags:

views:

50

answers:

2
SELECT * FROM `objects` WHERE (user_id IN ('7,8,12,9') AND visibility IN ('0,1'));

but it only returns the stuff corresponds to the second array's first element.
So it returns the same as like this:

SELECT * FROM `objects` WHERE (user_id IN ('7,8,12,9') AND visibility IN ('0'));

(I swapped the two values (of the visibility arg) and completely different set of results was returned. What I want, is both of results in one Query.

It's doing the same thing for the first array too. Only using the first value.

I would like the results from ALL the values.

+3  A: 

You need to quote each value if its a string:

SELECTobjectsWHERE (user_id IN ('7','8','12','9') AND visibility IN ('0','1'));

Or of youre actually dealing with integers you could do:

SELECTobjectsWHERE (user_id IN (7,8,12,9) AND visibility IN (0,1));

Also where is your FROM clause?

prodigitalson
If user_id is an integer, you shouldn't need ' around the numbers.
nos
+1  A: 

Your "IN" clause is wrong. It should be user_id in (7,8,12,9) or, if userid is character, user_id in ('7','8','12','9')

Paul Tomblin