Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Syntax Help
Message
From
10/07/1999 03:33:58
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00239121
Message ID:
00239778
Views:
10
>>>I'm often confused by whether I need to include all the fields I mention in my WHERE clauses when selecting fields for the result set, and it's just now coming to a head - perhaps someone here could clarify for me.
>>>
>>>Let's say for example I want a list of all the items ever purchased by a client, and those items are linked to the client number through a long tree:
>>>
>>>Clients ---- Invoices ---- InvDetail ---- Items
>>>
>>>Can I get this list by saying:
>>>
>>>SELECT Items.ItemName FROM Items, InvDetail, Invoices ;
>>> WHERE Invoices.ClientNo = "12345" ;
>>> AND InvDetail.InvoiceNo = Invoices.InvoiceNo ;
>>> AND Items.ItemNo=InvDetail.ItemNo ;
>>> ORDER BY 1 ;
>>> INTO CURSOR JustItems
>>>
>>>... or do I need to include clientno, both invoiceno's and both itemno's in the field list?????

>If I stick with the WHERE's to define the relationships, I need to include the fields in the field list, but if I do JOINs instead of WHEREs I won't have to???

I did that accidentally a couple of times back in 2.x, and it worked. Then I concluded you don't have to select all fields you use in the WHERE clause. Actually, you maintain two lists - the Where clause lists the conditions to pick the records, and the Select lists the fields to include in the resulting cursor. These two lists seem to be pretty independent.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform