mysql 行列 转换
表结构:
查询:
SELECT VALUE FROM yx_system_config WHERE menu_name in ('cuservice_phone','cuservice_weixin')
行列转换:
SELECT
MAX(CASE WHEN a.k1 = 'cuservice_phone' THEN a.v1 end ) as cuservicePhone ,
MAX(CASE WHEN a.k1 = 'cuservice_weixin' THEN a.v1 end ) as cuserviceWeixin
from
(
SELECT
menu_name as k1,
`value` as v1
FROM
yx_system_config
WHERE
menu_name in (
'cuservice_phone','cuservice_weixin'
)
) a;