Skip to content
Advertisement

MySQL where NOT IN except where one

I have threads table for forum. I don’t want select threads of hidden forums but except user’s own threads. My query like this and hidden forum ids in $hiddenforums variable so i want also select user’s own threads;

SELECT tid,uid,username
    FROM ".TABLE_PREFIX."threads
    WHERE fid NOT IN ($hiddenforums) /* HERE WHAT I WANT */ EXCEPT WHERE uid = $userownid /* */
    ORDER BY dateline
    DESC LIMIT 10

Advertisement

Answer

Is this what you want?

WHERE (fid NOT IN ($hiddenforums) OR uid = $userownid)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement