Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Querying using another table

Author  Topic 

viguro
Starting Member

12 Posts

Posted - 2008-04-30 : 14:33:28
Hello all,

I have a table (tbl_a) with 2 columns: itemNames | Date .
ItemNames can have duplicates.
I have another table (tbl_b) with date ranges in 2 columns: startDate | endDate.

what I would like to do is: query tbl_a where date between startDate and endDate of tbl_b.

does anyone have an idea?
thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-30 : 14:48:04
SELECT DISTINCT a.itemNames
FROM tbl_a a
INNER JOIN tbl_b b
ON a.Date >= b.StartDate
AND a.Date <= b.endDate
Go to Top of Page

viguro
Starting Member

12 Posts

Posted - 2008-04-30 : 15:21:14
it works like a charm! thanks a bunch visakh16!
Go to Top of Page
   

- Advertisement -