I have two tables which form a 1:many relationship.
For example,
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
Quote:
select * from parents left join child on parents.parentid=child.parentid
where (parents.degree='engineer' or child.degree='engineer')
group by child.parentid
|
But this query is leaving out the parent who doesn't have a child. How do I do this?