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

Join two tables with no link! 2

Status
Not open for further replies.

munchen

Technical User
Aug 24, 2004
306
GB
I have two tables tblA and tblB.

tblA contains the following fields:
Period,
StartDate,
EndDate

tblB contains the following fields:
ID,
Amount,
ReceivedDate

As you can see there is no way of linking these two tables but what I need is to prompt the user to enter a Startdate and Enddate (which looks at the Period field from tblA eg 200704). I would then display the ID and Amount fields from tblB where the ReceivedDate field is between the StartDate and EndDate fields in tblA.

The StartDate and EndDate fields in tblA display the start and end of each period.

Is there a way of linking the two tables even though there is no direct link?
 
you have a lot of arguments in your join criteria

e.g.

from
t1 inner join
t2 on a = b AND c = d or a between c and d

of course, you could just put it in the where clause, but that's anti ansi...

--------------------
Procrastinate Now!
 
To get you started....
Code:
[COLOR=blue]Select[/color] tblB.*, tblA.PeriodId
[COLOR=blue]From[/color]   tblB
       [COLOR=blue]Inner[/color] [COLOR=blue]Join[/color] tblA 
         [COLOR=blue]On[/color] tblB.RecievedDate Between tblA.StartDate and tblB.EndDate

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Maybe
Code:
SELECT a.*, b.*
FROM tblA a
JOIN tblB b ON b.ReceivedDate BETWEEN a.StartDate AND a.EndDate

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top