I have two entities - User and Subscription - where Subscription contains an instance of User (named user
). I'm trying to get all Subscriptions for a given user id with the following query:
SELECT sub FROM Resolute\ApiBundle\Entity\Subscription sub WHERE sub.user.id = 1
However it seems sub.user.id
is not the way to access this - what is the correct way?
You need to join the User object first:
SELECT s FROM Subscription s JOIN s.user u WHERE u.id = 1