Question: I currently have the following MySQL query, which executes fine without any errors:

```
SELECT topic_id,
       topic_title,
       topic_author,
       topic_type
FROM   forum_topics
WHERE  ( ( ( forum_id = '2' )
            OR ( forum_id != '4'
                 AND topic_type = 2 ) )
         AND deleted = 0 )
ORDER  BY topic_id DESC

```

However it's not doing what I intend it too, I want it to return all the results of topics WHERE the forum\_id is 2 and deleted equals 0 aswell as return the results of topics where the forum\_id does not equal 4 and the topic\_type is 2 and deleted equals 0 (if they exist).

But currently its just doing the first just returning results of topics WHERE the forum\_id is 2 and deleted equals 0 and not the other (even though they exist! :/).

I believe I'm doing something wrong...

All help is greatly appreciated.

Answer: 
I think your where clause would be something like this:

```
WHERE  ( (forum_id = '2' AND deleted = 0) 
         OR 
         (forum_id != '4' AND topic_type = '2' AND deleted = 0)
       )

```
Try this: 

```
SELECT topic_id, topic_title, topic_author, topic_type
FROM forum_topics
WHERE forum_id = 2
OR (forum_id != 4 AND topic_type = 2) 
AND deleted = 0 
ORDER BY topic_id DESC

```