Page 1 of 1

[SOLVED] Query malfunctions when go from 3 field parameters

Posted: Mon Jun 21, 2004 8:42 am
by cdickson
I am trying to display results drawing from 4 categories that are in my database. Currently I have 3 categories, and the results display correctly:

Code: Select all

$query_rsClothing = "SELECT * FROM Members WHERE cat_id1 = '213 OR 141 OR 183' OR cat_id2 = '213 OR 141 OR 183' OR cat_id3 = '213 OR 141 OR 183' ORDER BY member_name";
If I add one more category to the query, however, the results show only the category that I add, which in this case is "6":

Code: Select all

$query_rsClothing = "SELECT * FROM Members WHERE cat_id1 = '6 OR 213 OR 141 OR 183' OR cat_id2 = '6 OR 213 OR 141 OR 183' OR cat_id3 = '6 OR 213 OR 141 OR 183' ORDER BY member_name";
Am I limited to the number of "ORs" that I can put into a query? This really has me stumped since it seems so simple.

Posted: Mon Jun 21, 2004 9:11 am
by feyd
SELECT * FROM `Members` WHERE `cat_id1` IN(213,141,183) OR `cat_id2` IN(213,141,183) OR `cat_id3` IN(213,141,183) ORDER BY `member_name`

IN()

Posted: Mon Jun 21, 2004 9:20 am
by cdickson
Thanks, feyd. I knew it had to be easy.

But just so I understand, did my first syntax not work because of a limit on the number of "OR" operators a single command can handle?

Posted: Mon Jun 21, 2004 9:25 am
by feyd
numbers will only match against numbers.. so your first was turning that whole thing into '6'