Results 1 to 2 of 2

Thread: 1:N query help

  1. #1
    Join Date
    Aug 2003

    Unanswered: 1:N query help

    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
    select * from parents left join child on parents.parentid=child.parentid
    where ('engineer' or'engineer')
    group by child.parentid
    But this query is leaving out the parent who doesn't have a child. How do I do this?

  2. #2
    Join Date
    Apr 2005
    Baltimore, MD
    I believe you should be using a LEFT OUTER JOIN.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts