mysql - Query is not joining correctly, how do I fix it? -


i have large query structured this:

there bunch of tables main table lt_chc_tours_rsv_cs has t_dt column.

there ltr_chc_tours_rsv_price has season value.

there tr_season has season value of own (corresponding ltr_chc_tours_rsv_price) has start_dt , end_dt fields

what want in query join has p.season field has correspond a.t_dt date falls in between tr_season start_dt , end_dt , don't know how this.

i'm not sure if i'm explaining correctly.

tables

tr_season

season desc    start_dt   end_dt 1     s1      1/1/2013   12/31/2013 2     s2      1/1/2014   12/31/2014 3     s3      1/1/2015   12/31/2015 

ltr_chc_tours_rsv_price

season  price1   price2   price3 1        4         5        7 1        2         6        8      1        7         5        9    

lt_chc_tours_rsv_cs

t_dt      count 2/5/2013    6 2/7/2014    2 8/2/2015    3 

season's matched , counts multiplied pricing.

my query (unfinished)

select * -- bunch of stuff  lt_chc_tours_rsv_cs left outer join lv_customer_info1 b         on a.grp_attending = b.customer_no left outer join lv_chc_order_detail_info o  on a.order_no = o.order_no  left outer join ltr_chc_tours_rsv_price p   on /*this i'm stuck*/ 

what this?

select * -- bunch of stuff  lt_chc_tours_rsv_cs left outer join lv_customer_info1 b         on a.grp_attending = b.customer_no left outer join lv_chc_order_detail_info o  on a.order_no = o.order_no  join tr_season s     on a.t_dt between s.start_dt , s.end_dt join ltr_chc_tours_rsv_price p   on s.id = p.season  

this way can @ t_dt field , should between start_dt , end_dt , use id in field join.


Popular posts from this blog