Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding LEFT JOIN
Message
De
23/08/2005 14:05:15
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01042886
Message ID:
01043017
Vues:
27
>>>Well, of course I used the last syntax, e.g. I'm not THAT dump < g >. But I still fail to see the difference, though yours avoid using NULL and therefore more elegant.
>>
>>
>>I apologize a lot!
>>But you should be more precise when you say that it doesn't work
>>When it doesn't work, that results you get ?
>>
>>Elegant is a side effect.
>>
>>Can Viscodes.ccategory_description to be NULL ?
>>
>>A example where the two syntaxes are different:
>>
>>CREATE CURSOR T1 (AA I,BB I NULL)
>>INSERT INTO T1 VALUES (1,4)
>>INSERT INTO T1 VALUES (2,NULL)
>>INSERT INTO T1 VALUES (2,NULL)
>>
>>SELECT * FROM T1 LEFT JOIN T1 T2 ON T2.AA=T1.AA;
>>WHERE T2.BB=4 OR T2.BB IS NULL
>>
>>SELECT * FROM T1 LEFT JOIN T1 T2 ON T2.AA=T1.AA;
>>AND T2.BB=4
>>
>>
>>Except special cases,
>>it never needs to use WHERE outertable.field IS NULL
>>in a Left join on a outerfield that is not key primary
>
>Interesting, thanks a lot.
>
>In VisCodes, AFAIK, we don't have NULL in cCategory_Description. We were trying on my colleague computer the query with NULL. It brought records correctly, but for the code 0009 it didn't bring the records. I was looking in dis-belief, but haven't looked closely in VisCodes table for this code.
>

For code 0009 you have VisCodes.ccategory_description not like "REVENUE_CODES%",
these go into the join, but the where condition cut join result.
CREATE CURSOR T1 (AA I,BB I NULL,ccategory_description C(20))
INSERT INTO T1 VALUES (1,4,"REVENUE_CODES")
INSERT INTO T1 VALUES (2,7,"RATAPLAN")

SELECT Billing_charges.aa,Viscodes.BB,Viscodes.ccategory_description;
 FROM ;
     T1 Billing_charges ;
    JOIN T1 VisCodes ;
   ON Viscodes.BB=7;
 WHERE  Billing_charges.AA=2 ;
 AND (Viscodes.ccategory_description LIKE "REVENUE_CODES%";
  	OR  Viscodes.ccategory_description IS NULL)
  	
  	
SELECT *;
 FROM ;
     T1 Billing_charges ;
    LEFT OUTER JOIN T1 VisCodes ;
   ON Viscodes.BB=7;
   AND Viscodes.ccategory_description LIKE "REVENUE_CODES%";
 WHERE  Billing_charges.AA=2
Then this work:
...
where ... AND ( Viscodes.ccategory_description LIKE "REVENUE_CODES%";
 OR Viscodes.ccode_value IS NULL)
>Anyway, we switched to your query and it works.
>
>My new problem is comboboxes. Did you see my new thread? No one replied so far, so I take it as there is no way to control.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform