Solved

one to many join on two fields vfp

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 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