Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
3 table join
Message
From
16/02/2011 16:32:04
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01500313
Message ID:
01500450
Views:
37
>>Thanks for the code but it doesn't seem to give the desired result.
>>
>>For each PK in main the result should create N records where N = the largest number of matching records in Parts or Tools.
>>
>>main.pk = 1 has 2 parts records and 1 tools records so there should be 2 records in the result for pk = 1
>>main.pk = 2 has 1 parts record and 3 tools records so there should be 3 records in the result for pk = 3
>>
>>Your query gave 4 records for PK = 1 and 1 record for PK = 2 (and that record didn't find the matching tool record)
>>
>>It's looking as if I may need to rethink the entire process. My result would be fine if we were to export as an Excel spreadsheet (something we do often) but developing a hard copy REPORT FORM may be problematic.
>>
>>Thanks again........Rich
>>
>Rich,
>
>Did you have a chance to look at my suggestion? I assume that FK in both tables are sequential numbers with no gaps (if not, we need to add the numbers per each partition - a bit complex in VFP).

Yes. I've looked at your suggestion and responded to it. With a little tweak it gave the result I was looking for.

FK in Tools and Parts indicates the owning record from MAIN. The records in MAIN are not required to have any tool and/or parts record but the final result should include those records (NULL values for pno, tno, etc are acceptable).
Previous
Reply
Map
View

Click here to load this message in the networking platform