id key value id name height
1 name 高 =》 1 高 10
1 height 10
把左边的数据转为右边的。。。
SELECT owner,
MAX(CASE WHEN a.key = 'name' THEN a.val ELSE NULL END) as 姓名,
MAX(CASE WHEN a.key = 'age' THEN a.val ELSE NULL END) as 年龄
FROM `table1` as a
WHERE owner = 1 group by owner
嗯,给你满意吧。。。论哥