Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unexpected query result
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00483532
Message ID:
00489477
Vues:
18
Sorry to take so long in replying. Things have been extremely crazy here.

Anyway to answer your questions, to do the INNER JOINs, do something like:
SELECT a.company, b.order_date, b.shipped_on ;
   FROM customer a;
      INNER JOIN orders b ;
      ON b.cust_id = a.cust_id;
   WHERE b.order_date < {^1994-02-16}
This will return every record where the order date in Orders is less than 2/16/94. It will link the order with the appropriate customer record for every record returned.

If you simply want to return the customer information for the current order, do something like:
SELECT a.company ;
   FROM customer a;
   WHERE a.cust_id = Orders.cust_id
To return all orders for the current customer that fit the criteria, do something like:
SELECT b.order_date, b.shipped_on ;
   FROM orders b ;
   WHERE b.cust_id = Customer.cust_id AND;
      b.order_date < {^1994-02-16}
HTH

>>When you issue Query 1, VFP is looking for all records in table db1 where fld2a is equal to the current value of what's in fld2b from db2. The same sort of logic holds true for the second clause.
>>
>>So basically, you're telling VFP to return all records from both tables where certain fields in db1 match what's in the fields for the current record in db2.
>
>That much I understand (I've been using Foxpro & VfP since 1995). I came across this problem back then & got nowhere with MS support. Since then, I got into the habit of doing multiple queries to simulate the ANDs - because of the way the querying is done in the main application, it actually worked out better that way, having the partial results available for alternative queries saves time in many situations. It was another thread that reminded me & I thought I'd see if the problem had been cured.
>
>>I know most people say that for an INNER JOIN you don't have to specify it in the FROM clause of a SQL Select statement. However, my experience has been that when you want to join to tables in a query, you better indicate it in the FROM clause.
>
>Can you show me how you would do this ?
>
>This is one of the example from the current help file, my examples are not significantly different (I returned all fields just to cut down on typing).
>
>
>SELECT a.company, b.order_date, b.shipped_on ;
>   FROM customer a, orders b ;
>   WHERE a.cust_id = b.cust_id ;
>   AND b.order_date < {^1994-02-16}
>
>
>>If all you're trying to do is return matching records from db1 that match the current values of the current record in db2, then you can omit db2 from the FROM clause.
>
>How ?
>
>Sorry if I appear to be a little dim - it is Friday evening after a long week. But these results to seem a little disconcerting.
>
>With thanks for taking time to respond
Travis Vandersypen
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform