Skip to content

OR condition on different referencedTable(s) #29616

Closed Answered by a6z6
rrr3da asked this question in Feature Requests
Discussion options

You must be logged in to vote

Hi, I have the same question:

Say I have 2 tables, parents and kids.

parents:
name,
role,
age

kids:
name,
grade,
father_id,  // references parents
mother_id, // references parents

In the doc, it only teaches how to deal with one referenced table:
Say I wanna fetch all kids' name: who is in Grade 1 OR whose father is older than 30.

// Fetch all kids' name:  who is in Grade 1 OR whose father is older than 30.
.from("kids")
.select('''
name,
father:father_id!inner(age),
''')
.or('grade.eq.1,age.gt.30', referencedTable: 'father_id')

But what I wanna fetch is: all kids' name whose father is older than 30 OR mother is younger than 40.

// Fetch all kids' name whose father is older than 30 OR m…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rrr3da
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants