Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RIGHT OUTER JOIN not working
Message
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 7 SP1
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
01278885
Message ID:
01279369
Vues:
13
>>>NULL values are filtering out your WHERE statament. Try replacing aliases (i.e. LEFT instead of RIGHT JOIN), and Check for condition in "Liquid" instead of "visual".
>>>Please find code below:
>>>
>>>
>>>SELECT v.custid, l.custid, v.upsino, l.upsino, v.datinp, l.puldat, v.optemp, v.pktemp, l.ift, l.color;
>>>FROM liquid l ;
>>>LEFT OUTER JOIN visual v ;
>>>ON v.custid + v.upsino + DTOS(v.datinp) = l.custid + l.upsino + DTOS(l.puldat) ;
>>>WHERE l.custid = "AL100239" AND l.upsino = "0000001";
>>>ORDER BY v.upsino, v.datinp
>>>
>>
>>Zoran,
>>
>>Thank you. Your suggestion to check for condition in the "Liquid" instead of "Visual" works for me. However, I did not replace the aliases as you suggested, I actually have to join multiple tables to the Visual as shown below. I have to JOIN four more tables to the Visual. Am I correct in assuming that I can simply add each table with a RIGHT OUTER JOIN and add an OR condition to include that table?
>>
>>Here's what I'm trying now:
>>
>>
>>
>>SELECT v.custid, l.custid, v.upsino, l.upsino, v.datinp, l.puldat, v.optemp, v.pktemp, l.ift, d.hydrogen, i.aluminum ;
>>FROM visual v ;
>>RIGHT OUTER JOIN liquid l ON v.custid + v.upsino + DTOS(v.datinp) = l.custid + l.upsino + DTOS(l.puldat) ;
>>RIGHT OUTER JOIN dga d ON v.custid + v.upsino + DTOS(v.datinp) = d.custid + d.upsino + DTOS(d.puldat) ;
>>RIGHT OUTER JOIN icp i ON v.custid + v.upsino + DTOS(v.datinp) = i.custid + i.upsino + DTOS(i.puldat) ;
>>WHERE l.custid = "AL100239" AND l.upsino = "0000001" ;
>>OR d.custid = "AL100239" AND d.upsino = "0000001" ;
>>OR i.custid = "AL100239" AND i.upsino = "0000001" ;
>>ORDER BY v.upsino
>>
>>
>>Thanks again
>
>Hi Elgin,
>
>The above statement is definitely incorrect, it's even hard to predict what it will return because of OR conditions mixed with AND.
>
>I think it should be
>
>SELECT v.custid, l.custid, v.upsino, l.upsino, v.datinp, l.puldat, v.optemp, v.pktemp, l.ift, d.hydrogen, i.aluminum ;
>FROM visual v ;
>RIGHT OUTER JOIN liquid l ON v.custid + v.upsino + DTOS(v.datinp) = l.custid + l.upsino + DTOS(l.puldat) AND l.custid = "AL100239" AND l.upsino = "0000001";
>RIGHT OUTER JOIN dga d ON v.custid + v.upsino + DTOS(v.datinp) = d.custid + d.upsino + DTOS(d.puldat) AND d.custid = "AL100239" AND d.upsino = "0000001" ;
>RIGHT OUTER JOIN icp i ON v.custid + v.upsino + DTOS(v.datinp) = i.custid + i.upsino + DTOS(i.puldat) AND i.custid = "AL100239" AND i.upsino = "0000001";
>ORDER BY v.upsino
>
>
>but I'm not sure. Multiple table joins are very tricky, it would be easier to do it in multiple steps instead if possible and probably use LEFT JOIN instead.

Naomi,

Thanks for the advice on "multiple steps." I am finding that the more I get into this project, I will likely have to do this in multiple steps. I will probably start another thread soon coming at it from a different angle. And thank you for the info on the LEFT JOIN articles.
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform