Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Joining tables
Message
From
15/11/2001 11:39:06
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/11/2001 11:15:22
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00582131
Message ID:
00582159
Views:
25
This message has been marked as the solution to the initial question of the thread.
>I have the typical master, crossref, child set up. I'm trying to retrieve a particular child record, and having trouble.
>
>My master record links to 4 crossref records, which each link to 1 child record. I need to pull the child record with the location field of "MAIN"
>
>select master.*, child.altid as myfield ;
>from master ;
>left outer join crossref on master.id = crossref.id ;
>left outer join child on crossref.id2 = child.id2 and child.location = 'MAIN' ;
>where master.id = '1'
>
>
>
>The problem is that this creates 4 records in the result set -- and I only expect 1. I've simplified the problem a bit -- I have a feeling that there is a nuance of SQL syntax I'm missing. This select is going to end up in a veiw that I am using for reporting. If all else fails, I'll make seperate views and link em together with set relation -- I know that works ;-)

Todd,
Make second join and 'inner' join.
Also moving " and child.location = 'MAIN'" to where would work but having that in join sounds better to me.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform