How to match multiple field in mySQL

Posted by Mint on Stack Overflow See other posts from Stack Overflow or by Mint
Published on 2010-04-10T11:03:55Z Indexed on 2010/04/10 11:13 UTC
Read the original article Hit count: 284

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about phpbb

Related posts about php