PDA

View Full Version : MYSQL In Clause


paul41598
10-07-2009, 07:41 PM
If I had an IN ($groupids) in a query which were values 6,15 would that query only display results if it found exactly 6,15? What if 6 wasn't found, just 15?

Basically does the IN clause look for exact order and everything, or just any thing thats true in it?

Paul M
10-07-2009, 08:32 PM
6 or 15 :)

paul41598
10-08-2009, 11:25 AM
Thats what I thought, however my code:

WHERE usergroupid IN ($groupids)
OR membergroupids IN ($groupids)
OR FIND_IN_SET('$groupids', membergroupids)

only grabs users in group 6, and not 6,15 like I have selected.

--------------- Added 1255005593 at 1255005593 ---------------

n/m, I may have found my long outstanding issue. I can't use an IN when searching a DB column that has data in it such as 5,6,2. I have to use the FIND_IN_SET, but bigger yet, had to create loop to look through the array and then use the find in set. Phew!