SELECT id FROM products_product as LEFT JOIN products_vips as ON game_

1
2
3
4
5
6
7
SELECT p.id FROM products_product as p
LEFT JOIN products_vips as v ON v.game_id=p.game_id AND v.user_id=%s
WHERE CASE
WHEN p.visibility='v' THEN v.user_id is not null
WHEN p.visibility='i' THEN v.user_id is null
ELSE true
END