sql - Select from two different tables by value in third table -
i have next tables. first 1 a. have 2 columns: a_id , a_value. second table b. b have 2 columns: b_id , b_value in additional have table c. table c have c_id , bool columns c_bool if c_bool value == true need select value given id. if c_bool value == false need select value b. how can write select this? use oracle db.
thanks in advice.
select case c.bool when 1 a.id else b.id end join b on b.id = a.id join c on c.id = a.id
Comments
Post a Comment