I have an entity Person (p) which is related to an entity Notifications related to an entity NotificationType.
- Some persons have received a notification of type 1 (notification_type_id = 1).
- Some have received notifications but not of the type 1
- some haven't received messages at all.
Globally, I want to retrieve those who haven't received the messages of type 1.
I have written this query :
$qb = $this->createQueryBuilder('p')
->leftJoin('p.notifications', 'n')
->leftJoin('p.notification_type', 'nt')
->addSelect(array('p','n','nt'))
->where('nt.id NOT IN (1)')
->orderBy('p.name', 'ASC');
return $qb->getQuery()->getResult();
But with this query I only get those who have received notifications but not of type 1, I don't get those who haven't received notifications at all.
How can I rectify my query to have those ones ?
Thanks a lot for your help