How to match multiple field in mySQL

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.

Answers


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


Need Your Help

Default (fallback) Image with .htaccess?

.htaccess image default

I'm curious if it's possible to use .htaccess to serve up a default image when a particular image is requested that doesn't exist (note: only image-requests should raise this behavior). I know I co...

Summarising dataframe based on string values

r string dataframe dplyr plyr

I want to summarise a dataframe based on the unique values of a string variable.