Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding LEFT JOIN
Message
From
23/08/2005 10:51:42
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01042886
Message ID:
01042941
Views:
39
>>>Terrific! So, we just need to add OR IsNull(ccategory_description) part.
>>>
>>>Haven't thought about it.
>>>
>>>Thanks again for your sharp brain < g >
>>>
>>
>>
>>
>>SELECT Billing_charges.*, Viscodes.ccode_description;
>> FROM ;
>>     Billing_charges ;
>>    LEFT OUTER JOIN VisCodes ;
>>   ON  Viscodes.ccode_value LIKE ( Billing_charges.crevenue_code+"%" );
>>  AND Viscodes.ccategory_description LIKE ( "REVENUE_CODES%" )
>> WHERE  Billing_charges.cbilling_main_fk = ( ?vp_cBilling_main_fk )
>>
>
>These two queries are supposed to be the same. Can you explain the difference between these two? It looks like yours works every time, while the original with IsNull sometimes fails to work. I can not understand it.

Classic error: and ( logical multiplier ) priority!
WHERE  Billing_charges.cbilling_main_fk = ( ?vp_cBilling_main_fk )
AND Viscodes.ccategory_description LIKE ( "REVENUE_CODES%" )
OR Viscodes.ccategory_description IS NULL
* IS
WHERE ( Billing_charges.cbilling_main_fk = ( ?vp_cBilling_main_fk )
AND Viscodes.ccategory_description LIKE ( "REVENUE_CODES%" ) )
OR Viscodes.ccategory_description IS NULL
* CORRECT is
WHERE Billing_charges.cbilling_main_fk = ( ?vp_cBilling_main_fk )
AND (Viscodes.ccategory_description LIKE ( "REVENUE_CODES%" ) 
OR Viscodes.ccategory_description IS NULL)
But even if it works, this last form is not equivalent to mine;
the meaning in relational algebra sense it is different!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform