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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querying two tables at the same time w/out a common field

Status
Not open for further replies.

christak

MIS
Jul 14, 2003
20
US
Is there any way that I can query two tables at the same time without having a relationship between the two tables? There is absolutely no way to make a common field that is unique, but I'd like the report to show info from 2 tables at the same time.
Thanks!
Christa
 
Well you could but you would not get what you expect. A query without a relationship creates what's called a "cross-product". So for instance if you have the following 2 tables:

table1
Larry
Sue
John

table2
Apple
Orange
Pear

And you were to include them both in the same query without linking them:

select * from table1,table2

You would get something like:

Larry Apple
Larry Orange
Larry Pear
Sue Apple
Sue Orange
Sue Pear
John Apple
John Orange
John Pear

Mathematically a cross-product returns number of rows as:

table1 rows x table2 rows.

Back to the solution. You may want to create a report that has 2 embedded sub-reports in it, each based on one of your two tables.

Good luck.


Mike Pastore

Hats off to (Roy) Harper
 
On the other hand, you can generate SOMETHING which relates the records -or there is EVERY reason to NOT have both in the same query. One exception which MAY be of use (if at least the fields of interest are of the same number and types in the two tables is the UNION query. It is discussed to some degree in the ubiquitous {F1} arena and to a reasonable degree in all of the text re SQL / Relational data base.





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top