Solved

one to many join on two fields vfp

Posted on 2014-03-26
2
673 Views
Last Modified: 2014-03-26
Hi:
I am trying to compose a form which  displays deliveries made to a range of customers on a given day by a given wagon. Two tables: 'wagons' comprises wagons and the date on which they deliver; and 'customers' comprises customers, wagon, and date.
They should therefore join at wagon AND date. However vfp will not let me create more than one join in the data environment. Before I write in a field that concatanates the wagon and date in each table then singly joins this new field, I thought I should ask an expert.....
Thanks!
0
Comment
Question by:ClaytonGlass
2 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 250 total points
ID: 39955381
There are no joins but relations in VFP data environment. And relation cannot join two tables based on two different columns because it uses one index only.

So your options are
1) Concatenated column
2) No data environment but SQL query with your join:

SELECT c.* FROM Customers c
  INNER JOIN wagons w ON w.wagonID = c.wagonID AND w.date = c.date

3) You could also create a view from above SQL command and add this view into the data environment. It requires database container, e.g. :

CREATE DATABASE custwag
ADD TABLE customers
ADD TABLE wagons
CREATE SQL VIEW cwjoin AS SELECT c.* FROM Customers c INNER JOIN wagons w ON w.wagonID = c.wagonID AND w.date = c.date

The concatenated column provides the fastest response time because such column requires just one index for optimization.
0
 

Author Closing Comment

by:ClaytonGlass
ID: 39955385
Comprehensive as usual, thank you very much pcelba!
Gone for concatanated column.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now