Solved

one to many join on two fields vfp

Posted on 2014-03-26
2
667 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

13 Experts available now in Live!

Get 1:1 Help Now