views:

10

answers:

1

Im trying to match forum_id with several different forum_id's, something like forum_id = 5,7,12,43,63,78

I currently have this code:

SELECT topic_title, topic_id, forum_id 
FROM $MYSQL_TOPIC 
WHERE topic_title 
LIKE '%%%s%%' 
    AND forum_id = 5 
LIMIT 50

(using mysql_real_escape_string and sprintf)

I tried:

forum_id = 5 OR 7
forum_id = 5|7
forum_id = 5 AND 7
forum_id = 5 & 7

But none of them will match them all and therefore search though them all.

+3  A: 

forum_id IN (5,7,12,43,63,78)

Marcelo Cantos
I new the commas would have something todo with it :P Thanks. Do you have a link to where I can read up some more on this 'IN' command? (it's rather a common word and google doesn't like common words :P )
Mint
http://www.google.com.au/search?q=SELECT+WHERE+IN
Marcelo Cantos