列转行
表有字段a,b,c,d;要求
写一条sql语句可以根据a=1查出的效果:
a_1
b_2
c_2
d_4
表有字段a,b,c,d;要求
写一条sql语句可以根据a=1查出的效果:
a_1
b_2
c_2
d_4
select concat('a_',a) from table where a=1
union
select concat('b_',b) from table where a=1
union
select concat('c_',c) from table where a=1
union
select concat('d_',d) from table where a=1
;