What Kind of Join Do I need?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    What Kind of Join Do I need?

    I have two tables, i do a simple join on it (the only one i know how)
    but i want the results to show even though the join a.... ahh...

    here i can show you faster than i can tell you....

    Case table.
    id,
    caseNumber

    Trial table
    id
    caseID //foreign key to Case.id
    courtDate

    I want a query that gives me all the cases even though they dont' have a row in the Trial table.

    How do i do that?


    My query is simplified to show the point, but it involves 5 tables.

    Thanks in advance!


    Dan M.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    fixed it, i needed a LEFT JOIN!!



    SELECT c.id, c.caseNumber, t.courtDate FROM `case` as c LEFT JOIN trial as t ON c.id = t.caseID;


    ... just in case anybody else comes across this page.

    -D

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Glad you found it yourself. Maybe next time we'll be able to help a bit quicker.
      See you.

      Ronald

      Comment

      Working...