Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple Joins in a SELECT Statement for my Report
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00409594
Message ID:
00409759
Views:
14
>I am trying to create a SELECT statement consisting of multiple tables. The tables are parent=Nameplat, child1=Dga, and child2=Visual. All three tables have the fields Custid and Upsino in common. When I join just the Nameplat and Dga based on Custid+Upsino, it works perfectly and very speedy. However when I try to add the Visual table I get way too many records, over 4000 versus 462 in my test query. I plan on using this SELECT statement for the record source of my report, and I want to add a third table to it. This third table is a Parent over the Nameplat called CUST. Here's the SELECT statement I'm trying to make work:
>
>
>SELECT dga.upsino, dga.puldat, dga.hydrogen, ;
>nameplat.serial_no, nameplat.manufactur, nameplat.upsino AS "upsinoname", ;
>visual.optemp, visual.upsino AS "upsinovisual", visual.datinp ;
> FROM nameplat INNER JOIN dga ON nameplat.custid+nameplat.upsino=dga.custid+dga.upsino ;
> INNER JOIN visual ON dga.custid+dga.upsino=visual.custid+visual.upsino ;
>   INTO CURSOR rdga ;
>  WHERE dga.custid=gcCustid ;
>ORDER BY dga.upsino ASC, dga.puldat DESC, visual.datinp DESC
>REPORT FORM dga2 PREVIEW
>
>
>What am I doing wrong here? I have been trying this one for quite a while now. Will I be able to add Cust to this SELECT statement? Any help much appreciated.
>
>Thanks
>Elgin

Why you are JOINing on custid+upsino instead of something like nameplat INNER JOIN dga ON nameplat.custid = dga.custid AND nameplat.upsino = dga.upsino? There may be a reason to do so, but it's not the common way to join tables that are related on two fields. The outcome would depend on things like whether those two fields were numeric or character. If they are numeric, that could certainly explain why joining a third table gives you more records. For example, using your join, if a record in nameplat has custid = 3 and upsino = 7, it will JOIN with records in dga or visual that have custid = 2 and upsino = 8, and so on.
Previous
Reply
Map
View

Click here to load this message in the networking platform