Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Join six tables with single SELECT statement
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01316996
Message ID:
01319857
Views:
19
To all of you:

Thank you for your suggestions. After studying this situation for a few weeks and trying several options, Naomi's suggestion of using multiple SELECT statements and intermediate cursors seems to be working best for me. I was unable to accomplish what I needed in just one SELECT statement.

I have created six select statements that merge two tables each. Starting with the second SELECT statement, one of the two tables/cursors is the result set of the previous SELECT statement. I have a custom method, "mergefields" between each SELECT statement that gets data from then drops the duplicated custid and upsino data fields.

For brevity I have posted only two of the SELECT statements:
* Join the VISUAL and LIQUID tables into cursor "vl"
select * from visual v ;
	full outer join liquid l on v.custid = l.custid and v.upsino = l.upsino and v.datinp = l.puldat ;
	into cursor vl readwrite ;
	where v.custid = lcCustid and between(v.upsino, lcStartUpsino, lcEndUpsino) ;
        and between(v.datinp, ldStartDate, ldEndDate) ;
	or l.custid = lcCustid and between(l.upsino, lcStartUpsino, lcEndUpsino) ;
	and between(l.puldat, ldStartDate, ldEndDate) ;
	order by v.upsino, v.datinp

* Custom method to get data from then drop the duplicated custid, upsino, and data fields.
thisform.mergefields('vl')


* Join the "vl" cursor and the DGA table into cursor "vld"
select * from vl v ;
	full outer join dga d on v.custid = d.custid and v.upsino = d.upsino and v.datinp = d.puldat ;
	into cursor vld readwrite ;
	where v.custid = lcCustid and between(v.upsino, lcStartUpsino, lcEndUpsino) ;
	and between(v.datinp, ldStartDate, ldEndDate) ;
	or d.custid = lcCustid and between(d.upsino, lcStartUpsino, lcEndUpsino) ;
	and between(d.puldat, ldStartDate, ldEndDate) ;
	order by v.upsino, v.datinp

* Custom method to get data from then drop the duplicated custid, upsino, and data fields.		
thisform.mergefields('vld')
Thank you again.
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform