ronnyrr
ronnyrr

Reputation: 1561

MySQL find_in_set selecting not working

I'm trying to do the following:

But for some reason I don't get the results I want. See my following code:

SELECT   *, MONTH(datetime) AS month
FROM     $table_name
WHERE    YEAR(datetime) = $current_year
AND      find_in_set('%$user_id%', users)
AND NOT  find_in_set('%$user_id%', accepted) OR NOT find_in_set('%$user_id%', rejected)
ORDER BY datetime

Upvotes: 1

Views: 1300

Answers (1)

Ravinder Reddy
Ravinder Reddy

Reputation: 24012

Put the NOT clause condition in parenthesis.

WHERE    YEAR(datetime) = $current_year
AND      find_in_set('%$user_id%', users)
AND (    NOT find_in_set('%$user_id%', accepted) 
      OR NOT find_in_set('%$user_id%', rejected) )

Upvotes: 2

Related Questions