In Postgres, if I have :
Parent Table
id, name
1, Parent1
2, Parent2
.....
5, Parent5
Child Table
id, parent_id, name
1, 1, Child1
2, 1, Child2
.....
6, 2, Child6
.....
25, 5, Child25
so 5 children for each parent, how do I get, say, the first 3 children for parent id 1,3,4 in one query?
Best Answer
Assuming the "first" is defined through the
id
column in the child table, something like this should work: