How to determine selection of an instance based on the associated instance in a 1:M relationship? #17133
Unanswered
PawanKr3012
asked this question in
Help & Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have two models
Task
andTaskMember
Task
id: Primary key
added_by: Foreign key to user
title
TaskMember
id: Primary key
task_id: Foreign key to task
member_id: Foreign key to user
Both these model are associated using 1:M relationship.
In order to fetch all the tasks added by a user with there members i write the query as:
Now I want to only fetch those tasks where the tasks members do not have
member_id
same as the taskadded_by
I tried to achieve using the following query
But this query sekected all the tasks and didnot selected the task member instance where
member_id
was equal touser.id
I wanted to ignore the task as a whole.Please guide me on how to achieve my requirement.
Beta Was this translation helpful? Give feedback.
All reactions