Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal: Pull data from 1 of 2 tables?

Status
Not open for further replies.

mrtroy

Technical User
Jan 28, 2003
23
US
I need to pull data from 2 tables. I have current year data in table A and prior year data in table B, hence, the field names are identical. I need to be able to input a date range like 1/1/2003 through 6/4/2004 and get all the records that meet that criteria. There is no relationship between the current year and prior year data. My obvious problem is that if I select my criteria to filter on the data in table A, I will only get table A records. Can this be done?

T
 
Crystal Version ?
Database ?
Connectrivity Used ?

You can do this by using a UNION query to amalgamate the 2 tables together as 1 recordset i.e.

Select * FROM Table1
UNION
Select * FROM Table2

The best place to do this would be at the database end by creating a view which you can then use as your data source.

Or in CR 9 and 10 create a Command with the inputted SQL as your datasource

Or you will need to edit the sql in earlier verions.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Gary's answer is the best approach.

The only change I would make is to replace UNION with UNION ALL (which is much faster and appropriate in this case since you don't need to remove duplicates).

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top