The information in this article applies to:
SYMPTOMSWhen you specify a JOIN condition in a SQL Select statement using the ON clause, and you use the not equal sign (!=) with one empty table, the statement does not return any records. STATUSThis behavior is by design. MORE INFORMATIONON Clause with !=The following syntax does not return all the records from one table that do not have a matching record in the other table:SELECT * FROM tbl1 INNER JOIN tbl2 ON tbl1.fld1 != tbl2.fld1This creates a Cartesian product that excludes records that do match. Where Clause with !=To create a result set that includes all records from one table that do not exist in a second table, use the following syntax:SELECT * FROM tbl1 WHERE tbl1.fld1 != tbl2.fld1In conclusion, the following statements are not equivalent:
Steps to Reproduce BehaviorPlace the following code in a program file and run the code. Note that there are no records returned in the cursor.
For a demonstration of the Cartesian product, run the following code with
the database created in the code above open:
REFERENCESFor additional information, please see the following article in the Microsoft Knowledge Base: Q124589 How to Create a Left-Right Outer Join in FoxPro for Windows Additional query words: SQL Select
Keywords : kbVFp kbVFp500 kbVFp500a kbVFp600 FxprgGeneral FxprgSql |
Last Reviewed: December 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |