MySQL complex WHEN filter with CASE -


i'm trying figure out how filter output "combination" case. first 2 statements work , me lessons want (i.e., snowboard lessons @ skier's ability level + unrated private lessons). third statement (inpreferredlessontype = 3, is, either snowboard or ski) fails filter output set properly--i snowboard lessons or ski lessons various ability levels match either of skier's 2 (separately stored) ability levels. not right idea, , confusing user.

what i'd snowboard lessons @ skier's snowboard ability level + ski lessons @ skier's ski ability level + unrated private lessons. please help!

(...rest of select statement...)

case  when inpreferredlessontype = 1    program.nbool_issnowboard = 0 ,  (program.n_ability_level = inskiabilitylevel or program.n_ability_level = 0)    when inpreferredlessontype = 2   program.nbool_issnowboard = 1 ,  (program.n_ability_level = insnowboardabilitylevel or program.n_ability_level = 0)    when inpreferredlessontype = 3   program.n_ability_level = inskiabilitylevel         or program.n_ability_level = insnowboardabilitylevel        or program.n_ability_level = 0    end 

(...rest of filter statements, order by, etc.)

turns out needed bracket conditions , filter ski vs. snowboard ability levels.

when inpreferredlessontype = 3       (program.nbool_issnowboard = 0 , program.n_ability_level = inskiabilitylevel)              or             (program.nbool_issnowboard = 1 , program.n_ability_level = insnowboardabilitylevel)             or              program.n_ability_level = 0 

Comments

Popular posts from this blog

r - how do you merge two data frames the best way? -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

php - mySQL problems with this code? -