Mysql
 sql >> Database >  >> RDS >> Mysql

Utilizzo di My SQL join

Invece di 'salta', impostalo in modo che il valore non sia vero, usando NOT:

SELECT *
FROM posts p
JOIN relations r ON p.user_id = r.recipient
WHERE (r.status = 1 OR r.status = 2)
AND (r.sender = '$user_id' OR p.user_id = '$user_id')
AND NOT (r.status = 1 AND p.privacy = 2 AND p.user_id != '$user_id')
ORDER BY p.post_id DESC;"