Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select problem with 3 Tables
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01084546
Message ID:
01084549
Views:
8
This message has been marked as the solution to the initial question of the thread.
Maybe you have duplicate 'prodno' in the product table for that duplicated row?

>I am having a problem with an SQL Select joining 3 tables.
>First I tried it out using only 2 tables:
>
>
> SELECT Customers.orderid, Customers.datesold, Customers.firstname,;
>  Customers.lastname, OrderDTL.prodno, OrderDTL.quantity, OrderDTL.saleprice;
> FROM ;
>     MYDBC!OrderDTL ;
>    INNER JOIN MYDBC!CUSTOMERS ;
>   ON  OrderDTL.orderid = Customers.orderid;
> WHERE  Customers.datesold = ( ?ddate );
> ORDER BY Customers.lastname, Customers.firstname
>
>
>This code obtains the correct number of records for each date I enter for DDATE
>
>Now I add the one field I need from the third table to this Select: products.prodname
>
>
>SELECT Customers.orderid, Customers.datesold, Customers.firstname,;
>  Customers.lastname, OrderDTL.prodno, OrderDTL.quantity, OrderDTL.saleprice, products.prodname;
> FROM ;
>     MYDBC!OrderDTL ;
>    INNER JOIN MYDBC!CUSTOMERS ;
>   ON  OrderDTL.orderid = Customers.orderid;
>   INNER JOIN MYDBC!PRODUCTS ;
>   ON OrderDTL.prodno = Products.prodno;
> WHERE  Customers.datesold = ( ?ddate );
> ORDER BY Customers.lastname, Customers.firstname
>
>
>But the results are that I get one duplicated record for each date I try. Only 1 record appears twice while all the other records appear only once.
>
>Is this a VFP/SQL quirk or what am doing wrong?
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform