Q+E: Using Outer Join Operators to Include Nonmatching Records

Last reviewed: November 2, 1994
Article ID: Q76781

SUMMARY

Q+E supports the use of Outer Join operators. These operators are used to display records that are normally excluded from the joined query because they do not match in both tables.

MORE INFORMATION

Outer Join Operators

  1. *= Includes all the rows from the first table in the results, not just the ones in which the joined columns match

  2. =* Includes all the rows from the second table in the results, not just the ones in which the joined columns match

Below is an example of how these operators might be used is an Excel macro.

Note: This example uses macro functions supplied by the add-in QE.XLA. You must open the QE.XLA before executing this example.

   A1  =DB.LOGON('sqlserver')
   A2  =ACTIVATE("sheet1")
   A3  =DB.SQL.QUERY(2,"use pubs; select au_fname, au_lname, pub_name
        from sqlserver | authors, publishers
        where authors.city *= publishers.city",1,FALSE)
   A4  =RETURN()

This macro will open two SQL Server tables and do a join on the "CITY" field of each table. Records in the table "authors" that do not have a match in the table "publishers" will be included in the result.

It is not possible to include nonmatching records from both tables using the SQL operators.

REFERENCES

"Q+E for Microsoft Excel User's Guide," version 3.0, pages 70 and 103

"Quick Reference Guide to SQL," Microsoft Press, pages 64-67


KBCategory: kbother
KBSubcategory:

Additional reference words: noupd


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: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.