tags:

views:

26

answers:

2

I am probably overlooking something simple--

Some of the news items has 2 categories checked, and other times it has all 4 check. I know I can do OR '' OR '' OR '' OR '' -- but I think there is a better way.

The question: How could I query this to output: if the story has category 10,13 or 10,13,15 or 10,13,15,16 or 10,15 or 10,13?? ('10' is the parent category) -- without doing a query like that??

WHERE news.id = story.post_id AND news.category LIKE '10,13,15,16'
A: 
WHERE news.id = story.post_id AND news.category in (10, 13, 15, 16)
cherouvim
+1  A: 

You could say:

AND new.category IN ('10,13', '10,13,15', '10,13,15,16', '10,15', '10,13')

Which is slightly cleaner that using many OR's.

Justin Ethier
Thanks. I didn't realize you can query "IN" ha.
eberswine