Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query Help part 1
Message
From
19/10/2004 08:25:49
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00952380
Message ID:
00952570
Views:
6
>The WHERE clause makes me lose records from table1, if the table2.field3 is not greater than 5. If I start with 25 records in table1, I want to end up with 25 records in table1. Just want the field3 added if it mets the criteria, otherwise i want field3 to be blank.
>
>>Try
>>
>>SELECT Table1.Cust_No, Table1.Field1, Table1.Field2, Table2.Field3 ;
>> FROM Table1 LEFT OUTER JOIN Table2 ;
>> ON Table1.Cust_No = Table2.Cust_No ;
>> WHERE Table2.Field3 > 5
>>Regards,
>>Jim
>

In cases like this, you need to move the filter condition into the join condition:

SELECT Table1.Cust_No, Table1.Field1, Table1.Field2, Table2.Field3 ;
FROM Table1 LEFT OUTER JOIN Table2 ;
ON Table1.Cust_No = Table2.Cust_No ;
AND Table2.Field3 > 5

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform