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

Merging unrelated tables 1

Status
Not open for further replies.

dhulbert

Technical User
Joined
Jun 26, 2003
Messages
1,136
Location
GB
I have 2 tables with no common field between them
Table A has a staff list and Table B has a list of dates

How do I create 1 table with a row for every Staff member and date

So

Table A Table B

Dave 01/01/2010
Fred 02/01/2010
Sue

Final Table

Dave 01/01/2010
Dave 02/01/2010
Fred 01/01/2010
Fred 01/02/2010
Sue 01/01/2010
Sue 02/01/2010

Cheers.




I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
 
This is exactly what a cross join is used for.

Code:
Select TableA.StaffName, TableB.DateColumn
From   TableA
       Cross Join TableB

Notice there is no ON clause or where clause.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Doh.

I thought I'd tried every join I could think of, never thought of that one.

Cheers.

I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top