i have following code:
SELECT *
FROM table
WHERE thread = $thread
AND (user != $user1 OR user != $user2)
i want the code to pick all rows that contains $thread BUT the user isn’t $user1 or $user2.
is my code correct? or should it be like:
SELECT *
FROM table
WHERE thread = $thread
(AND user != $user1 OR user != $user2)
thanks in advance
Use this:
Because you don’t want if the user is either of user1 or user2, for this reason using ‘AND’ will be proper option here.
Also if the
$threadis not an integer field, you need enclose it in quotes eg: