Reputation: 65173
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.
Upvotes: 0
Views: 205
Reputation: 182832
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')
Upvotes: 1
Reputation: 60413
You need to quote each value if its a string:
SELECT
objectsWHERE (user_id IN ('7','8','12','9') AND visibility IN ('0','1'));
Or of youre actually dealing with integers you could do:
SELECT
objectsWHERE (user_id IN (7,8,12,9) AND visibility IN (0,1));
Also where is your FROM
clause?
Upvotes: 3