Expertz plz plz HELP 🙁
i have a relationship table
r_id usera userb active
13 5 1 0
16 1 2 0
now i want to check if some other users are friends with id no 1 and give me other ids except 1
like for this query i expect the ans to be empty because the condition active=1 is not met
if the condition returns true than i would expect the result as 5,2
so i have formed this query
note:user_id keeps on changing depending upon the session
$user_id = 1
SELECT CASE
WHEN `usera`=$user_id
THEN `userb`
ELSE `usera` END
FROM `relationship`
WHERE `usera`=$user_id
OR `userb`=$user_id and `active`='1'
now the problem is even if the conditon is not met(i.e active=1) it still gives me userb
i want the query to return as empty or null
Thanks,
You are missing some parentheses:
or even this which is probably what you are looking for: