mysql - Time Dependent Joins -
i have 2 tables have start , end date each each on both tables , need join them record valid dates on both tables
table 1 empid startdate enddate 1 1/2/2017 12/31/9999 1 8/10/2016 1/1/2017 1 10/11/2015 8/9/2016 1 2/10/2014 10/19/2015 table2 jobid empid startdate enddate j1 1 1/2/2017 12/31/9999 j2 1 8/10/2016 1/1/2017 j3 1 2/10/2014 8/9/2016 result set should empid startdate enddate 1 1/2/2017 12/31/9999 j1 1 8/10/2016 1/1/2017 j2 1 10/11/2015 8/9/2016 j3 1 2/10/2014 10/19/2015 j4
thanks in advance sri
you can test query this:
select t1.* ,t2.jobid table1 t1 left join table2 t2 on t1.empid = t2.empid , t1.startdate = t2.startdate , t1.enddate = t2.enddate;
Comments
Post a Comment