Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    6

    Unanswered: query code problem.

    i have three tables table1, table2 and table3.

    select * from table1, table2, table3
    where table1.ID = "IDnumber"
    table1.ID = table2.ID
    table1.ID = table3.ID

    if table3 doesnt have any rows with a matching IDnumber it wont return any results even if table1 and table2 have rows with the same IDnumber. how can i modify my query so i get a rows even if there are no rows on table3...

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd use a LEFT JOIN if I wwanted to do that.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Oct 2003
    Posts
    6
    i'll research that... thank you... wow fast reply... =)

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    We aim to please!

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Oct 2009
    Posts
    2
    select * from table2 JOIN table1 ON table1.ID = table2.ID JOIN table3 ON table1.ID= table3.ID


    //This should join all three tables based on their IDs and you should be able to select anything from each table. Hope it helps

  6. #6
    Join Date
    Oct 2003
    Posts
    6
    thank you guys. i got it working with the "LEFT 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
  •