Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RIGHT OUTER JOIN not working
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01278885
Message ID:
01279183
Views:
14
>>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.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform