Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2002
    Posts
    34

    Angry Unanswered: Left Join Problem?

    My SQL looks like this:

    SELECT tblname1.field1,tblname2.field2,tblname3.field3,tb lname4.field4
    FROM ((tblname1 LEFT JOIN tblname2 ON tblname1.field1=tblname2.field2) LEFT JOIN tblname3 ON tblname2.field2=tblname3.field3) LEFT JOIN tblname4 ON tblname3.field3=tblname4.field4;

    Can anyone tell me why this isn't working?

    Any help would be excellent.
    Thanks,
    SD

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what does "not working" mean?

    you may have to give sample values so that we can test this out ourselves...


    rudy
    http://rudy.ca/

  3. #3
    Join Date
    Dec 2002
    Posts
    34
    Originally posted by r937
    what does "not working" mean?

    you may have to give sample values so that we can test this out ourselves...


    rudy
    http://rudy.ca/
    It actually gives me an ODBC error but when I remove the last join the query runs fine.

    ODBC error or SQL?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    NFI -- no idea

    try an extra level of parentheses around the whole FROM clause

    those parentheses are required by microsoft access, but if you're using ODBC, this suggests that your query involves linked tables -- and if the query is getting handed over to some other database, it might not like those parentheses

    investigate whether a "passthru" query is what you need...


    rudy

  5. #5
    Join Date
    Dec 2002
    Posts
    34
    Originally posted by r937
    NFI -- no idea

    try an extra level of parentheses around the whole FROM clause

    those parentheses are required by microsoft access, but if you're using ODBC, this suggests that your query involves linked tables -- and if the query is getting handed over to some other database, it might not like those parentheses

    investigate whether a "passthru" query is what you need...


    rudy
    Yes I am using linked tables but no other database. Not sure what a passthru is. Fairly new at this.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    here's what the help file says in Access 97 --

    Send commands to an SQL database using a pass-through query

    Microsoft Access pass-through queries send commands directly to an ODBC database server (such as Microsoft SQL Server). With pass-through queries, you work directly with the tables on the server instead of linking to them.

    1 In the Database window, click the Queries tab, and then click New.

    2 In the New Query dialog box, click Design View, and then click OK.

    3 Without adding tables or queries, click Close in the Show Table dialog box.

    4 On the Query menu, point to SQL Specific, and then click Pass-Through.

    5 On the toolbar, click Properties to display the query property sheet.

    6 In the query property sheet, set the ODBCConnectStr property to specify information on the database to which you want to connect. You can type the connection information, or click Build , and then enter information about the server you're connecting to.

    For details on the syntax for your query, see the documentation for the SQL database server to which you're sending the query.

    7 If the query isn't the type that returns records, set the ReturnsRecords property to No.

    8 In the SQL Pass-Through Query window, type your pass-through query.

Posting Permissions

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