mysql - Join two sql queries into one -
i have 2 mysql queries , combine them one.
this 1 "merges" 2 columns one.
select description case when checkbox2 = '2' '2' when checkbox2 = '1' '1' when checkbox2 = '0' '0' when checkbox1 = '1' '1' when checkbox1 = '0' '0' end 'checkbox_merge', table2 left join table3 on table2.id2 = table3.id2 order table2.id2 this 1 takes 2 tables , pivots names (a->d) , uses them columns draw grid if will.
select description max(case when column1 = 'a' checkbox1 else '-' end) 'a', max(case when column1 = 'b' checkbox1 else '-' end) 'b', max(case when column1 = 'c' checkbox1 else '-' end) 'c', max(case when column1 = 'd' checkbox1 else '-' end) 'd', table1 join table2 on table2.id = table1.id table2.id = var1 , table1.id = var1 group description so take first query , use checkbox_merge in place of checkbox1 in second query.
any ideas how accomplish this?
try this:
select description, max( case when column1 = 'a' ( case when checkbox2 = '2' '2' when checkbox2 = '1' '1' when checkbox2 = '0' '0' when checkbox1 = '1' '1' when checkbox1 = '0' '0' end ) else '-' end ) 'a' table1 join table2 on table2.id = table1.id left join table3 on table2.id2 = table3.id2 table1.id = var1 group description
Comments
Post a Comment