var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: 1:N query help
I have two tables which form a 1:many relationship.
The main table A can be:
1 ParentA graduate
2 ParentB doctor
3 ParentC engineer
and Child table can be
1 1 ChildA1 6th grade
2 1 ChildA2 graduate
3 1 ChildA3 engineer
4 2 ChildB1 doctor
Now you see, that parentA has three childs, parentB has 1 and parentC has none.
I would like to know those parents who are engineers or whose children might be engineers.
So I tried a query like
But this query is leaving out the parent who doesn't have a child. How do I do this?
select * from parents left join child on parents.parentid=child.parentid
where (parents.degree='engineer' or child.degree='engineer')
group by child.parentid
I believe you should be using a LEFT OUTER JOIN.