Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select - WHERE clause VS JOIN clause to join tables?
Message
 
To
05/07/1998 19:36:49
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00114389
Message ID:
00114404
Views:
14
>And lastly, what would be the equivalant join clause for the following query to join cust & invoice?? inner, left, etc?? I don't know which join is equivalant to the old fox 2.x method and can't find a documentation on it.
>
>select cust.custno, cust.name, invoice.date, invoice.total ;
>from cust, invoice ;
>where cust.custno = invoice.custno ;
>and invoice.date = {06/30/98} ;
>into cursor temp
>
>TIA -Rick
Rick,

I don't know whether JOIN is faster than WHEN or not, I don't think there is much difference between them related to performance. Using JOIN is moe with the SQL standard though.

Your SELECT would be stated;
SELECT cust.custno, cust.name, invoice.date, invoice.total ;
  FROM cust JOIN invoice ON Cust.Custno = Invoice.Custno ;
 WHERE invoice.date = {06/30/98} ;
  INTO CURSOR temp
The join in the where clause is a simple, or INNER, join. To produce OUTER joins in using the WHERE clause requires a sub-select as in;
SELECT cust.custno, cust.name, invoice.date, invoice.total ;
  FROM cust, invoice ;
 WHERE cust.custno = invoice.custno ;
   AND invoice.date = {06/30/98} ;
UNION ;
  SELECT Cust.Custno, Cust.Name, {}, 0000.00 ;
    FROM Cust ;
   WHERE Cust.Custno NOT IN (SELECT Custno FROM Invoices) ;
INTO CURSOR temp
The above syntax will produce a LEFT OUTER JOIN.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform