Alternative to PHQL not supporting Subqueries

Hello,

Do you know how can I do this query with join? PHQL doesn't support subqueries wich is a big pain.

SELECT * FROM location WHERE id NOT IN (SELECT location_id FROM user_location WHERE user_id=1000);

I have two tables: one with locations and one with likes and dislikes from user to those locations. I want to retrive all the locations that the user didn't voted yet. I don't want to appear locations that the user allready voted.

Thank you so much!



35.1k

Something like this might work

SELECT l.* FROM user u JOIN location l ON (u.id = 1000 AND l.id != u.location_id)