I'm building a system with messages that can be assigned to (one or more) users.
Table: Messages
- id
- text
Table: Assignments
- id
- remark
- status
Table: Assignment_User
- id
- assignment_id
- user_id
Table: Users
- id
- name
Now I want to retrieve all assigned messages for a specific user
$qb->select('DISTINCT m')
->from('MessageBundle:Assignment', 'a')
->join('MessageBundle:Message', 'm')
->join('MessageBundle:AssignmentUser', 'au')
->where('a.message = m')
->andWhere('au.assignment = a')
->andWhere('a.status = (:assigned)')
->setParameter('assigned', 'assigned')
->orderBy("mr.createdAt", "desc");
As soon as I add that second JOIN it throws an error... Error: Expected Literal, got 'JOIN'
What would be the correct way to get all assigned messages for user X?