SQL Server multiple conditions from table -


table1 contains distinct list of members , respective date ranges

member_id   |  date_start   |  date_end 

table2 large data set contains large list of entries members, many entries many members

member_id   |  date   |   value 

what sql server query need implement retrieve entries table2 meeting conditions table1? want retrieve entries table2 falling between date_start , date_end respective member_id.

you need use join:

select * `table1` t1 left join `table2` t2 on t1.member_id = t2.member_id t2.date between t1.date_start , t1.date_end 

if want entry table2 replace * t2.*

you can have well: http://dev.mysql.com/doc/refman/5.0/en/join.html


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -