MSQuery Err Msg: "Query Can Have Only One Outer Join"

Last reviewed: July 2, 1997
Article ID: Q115340
1.00 WINDOWS kbusage kberrmsg kbtool

The information in this article applies to:

  • Microsoft Query for Windows, version 1.0
  • Microsoft Excel for Windows, version 5.0
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Office 97 for Windows

SYMPTOMS

In Microsoft Query 1.0, if you attempt to create more than one outer join, you will receive the following error message:

   Query can have only one outer join

CAUSE

Microsoft Query version 1.0 is limited to one outer join between two tables (Microsoft Query can perform several inner joins and/or a single outer join in a query).

WORKAROUND

To work around this limit, you can create multiple outer joins by modifying the SQL statement containing the single outer join so that it performs multiple outer joins.

After you make the modification, Microsoft Query will not be able to display the multiple outer joins, but it will be able to display the resulting query.

WARNING: Your use or modification of the SQL statement provided in this article is at your own risk. Microsoft provides this SQL statement "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Microsoft does not support modifications of the SQL statement to suit specific customer requirements.

The following is an example of a double outer join using two related dBASE tables. In order for the example to work correctly, you must have a data source installed for the dBASE file format.

Creating Sample Databases

  1. In Microsoft Excel, create the following table:

          A1: FIRSTNAME     B1: LASTNAME       C1: LETTER
          A2: John          B2: Smith          C2: a
          A3: Sam           B3: Smith          C3:b
          A4: Mike          B4: Smith          C4: c
          A5: Jack          B5: Johnson        C5: d
          A6: John          B6: Johnson        C6: e
          A7: Sam           B7: Johnson        C7: f
          A8: Mike          B8: Johnson        C8: g
    
    

  2. From the File menu, choose Save As. Save the file in the dBASE file format, and name it EMPA.DBF.

  3. On a new worksheet, create another table with the following information:

          A1: FIRSTNAME     B1: LASTNAME       C1: COUNT
          A2: Sam           B2: Johnson        C2: 6
          A3: Mike          B3: Johnson        C3: 7
          A4: George        B4: Smith          C4: 1
          A5: Sam           B5: Smith          C5: 2
          A6: Mike          B6: Smith          C6: 3
    
    

  4. From the File menu, choose Save As. Save the file in the dBASE file format, and name EMPB.DBF.

Creating Two Outer Joins

  1. Start Microsoft Query, and choose New Query from the File menu.

  2. In the Select Data Source dialog box, it choose dBASE files, and choose
the
   Use button.

  • In the Add Tables dialog box, add the EMPA.DBF and EMPB.DBF dBASE files that you created in the "Creating Sample Databases" section above, and then choose Close.

  • From the Table menu, choose Joins. In the Joins dialog box, choose empa.FIRSTNAME from the Left list, choose = from the Operator list, and choose empb.FIRSTNAME from the Right list. Select the second option in the Join Includes group to specify a LEFT OUTER join, and then choose ADD, and then Close.

  • Double-click the * for the empa table, then double-click the * for the empb table.

    All of the fields will be added to the query.

  • Click the View SQL button on the toolbar.

    The following SQL statement will be displayed:

          SELECT empa.FIRSTNAME, empa.LASTNAME, empa.LETTER, empb.FIRSTNAME,
          empb.LASTNAME, empb.COUNT FROM {oj c:\wow\empa.dbf empa LEFT OUTER
          JOIN c:\wow\empb.dbf empb ON empa.FIRSTNAME = empb.FIRSTNAME}
    

  • Starting from the "ON" portion of the statement, modify the SQL statement so that it matches the following statement:

          SELECT empa.FIRSTNAME, empa.LASTNAME, empa.LETTER, empb.FIRSTNAME,
          empb.LASTNAME, empb.COUNT FROM {oj c:\wow\empa.dbf empa LEFT OUTER
          JOIN c:\wow\empb.dbf empb ON (empa.FIRSTNAME = empb.FIRSTNAME and
          empa.LASTNAME=empb.LASTNAME.}
    

  • In the SQL Statement dialog box, choose OK.

  • When you get the "SQL Query can't be represented graphically. Continue anyway?" message, choose OK.

    You will then have your double outer join. The results are below:

       FIRSTNAME  LASTNAME   LETTER   FIRSTNAME  LASTNAME  COUNT
       John       Smith       a
       Sam        Smith       b        Sam        Smith     2
       Mike       Smith       c        Mike       Smith     3
       Jack       Johnson     d
       John       Johnson     e
       Sam        Johnson     f        Sam        Johnson   6
       Mike       Johnson     g        Mike       Johnson   7
    
    

    MORE INFORMATION

    Joins are used in Microsoft Query version 1.0 to associate tables using common fields. In a two table example, an outer join retrieves all the records from one table and only those records from the other table for which values in the joined fields are equal.

    REFERENCES

    "Microsoft Query User's Guide," pages 102-113


  • KBCategory: kbusage kberrmsg
    KBSubcategory: xlquery

    Additional reference words: 5.00 howto

    Keywords : xlquery kberrmsg kbusage
    Version : 1.00 7.00 97
    Platform : WINDOWS


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: July 2, 1997
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.