Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Posts
    2

    Unanswered: Access SQL left join question

    I am trying to write a small app that we can use as an intranet hours tracker. Basic SQL select from where kinda stuff. The DB is relational, and so i need to do two left joins between three tables (the two with keys (UINs) and one with two corresponding columns of foreign keys.

    Can anyone show me the basic syntax for two left joins?

    I know it basically goes SELECT * FROM tblwforeginkeys LEFT JOIN tblwkey ON (whatever I want to join on)


    But what happens when I want to LEFT JOIN another table to the table "tblwforeginkeys"? is it:

    I know it basically goes SELECT * FROM tblwforeginkeys LEFT JOIN tblwkey ON (whatever I want to join on) LEFT JOIN tblwkey2 ON (whatever I want to join this table on)

    I tried that and got an error from MS access.

    Anyone know?

    Thanks,
    Ari
    anepon@mrbcomm.com

  2. #2
    Join Date
    Mar 2002
    Posts
    192
    What kind of error do you recieve from access? is it an ambiguous join kind of thing?

  3. #3
    Join Date
    Mar 2002
    Posts
    192
    If this is the case you need to split the query into two queries.

    one with table A left join table B called Query 1
    then the toher with table C left joined Query 1 called Query 2.

  4. #4
    Join Date
    May 2002
    Location
    London
    Posts
    87
    Noramlly you are ok if there are only left joins and no inner joins beyond the initial left. I.e.
    Code:
    SELECT tblBalanceSheet.Account, tblCurrentAccountReclass.AdjAmount, tblReclassMaster.Title
    FROM (tblBalanceSheet LEFT JOIN tblCurrentAccountReclass ON tblBalanceSheet.Account = tblCurrentAccountReclass.SourceAccount)
    LEFT JOIN tblReclassMaster ON tblCurrentAccountReclass.AdjID = tblReclassMaster.AdjustmentID;
    works but
    Code:
    SELECT tblBalanceSheet.Account, tblCurrentAccountReclass.AdjAmount, tblReclassMaster.Title
    FROM (tblBalanceSheet LEFT JOIN tblCurrentAccountReclass ON tblBalanceSheet.Account = tblCurrentAccountReclass.SourceAccount)
    INNER JOIN tblReclassMaster ON tblCurrentAccountReclass.AdjID = tblReclassMaster.AdjustmentID;
    doesn't

Posting Permissions

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