Reputation: 1
I am new to SQL and am trying to join 2 tables on MySQL: one with a date and another with date range.
Table 1 contains:
Service date (e.g. 2017-01-01)
Vendor City
Vendor ID
Vendor Name
Sales
Table 2 contains:
Special Date ID
Special Date Description
Special Date range from (e.g. 2016-12-30)
Special Date range to (e.g. 2016-01-03)
Vendor City
Vendor ID
I want to left join these two tables where the service date is between the special date range.
Would anyone can suggest good SQL statement for using above example?
Thank you,
Upvotes: 0
Views: 101
Reputation: 1271023
Use between
or inequalities:
select . . .
from t1 join
t2
on t1.service_date between t2.start_date and t2.end_date;
Upvotes: 1