Last post Sep 16, 2012 11:07 PM by oned_gk
Sep 16, 2012 10:35 PM|hkbeer|LINK
I have a mdb file with 2 Tables
One is MainData Table
Then I have another Table which hold PeriodName
P1, 1/4/12, 2/23/12
I want to add to Table1 the PeriodName in Table2 where Date in Table1 falls between From/To in Table2.
What is the SQL ?
Desired result as follow
Apple, 1/6/2012, P1
Orange, 1/9/2012, P8
Thanks a lot in advance
Sep 16, 2012 11:07 PM|oned_gk|LINK
Try this :
SELECT Table1.Type, Table1.Date, Table2.PeriodName, Table2.From, Table2.To
FROM Table1 LEFT JOIN Table2 ON (Table1.Date <=Table2.To) AND (Table1.Date >= Table2.From);