select ?user_name,(select eq_name from `test_game` b where b.user_name = a.user_name and b.equipment = 'arms' ) as arms,(select eq_name from `test_game` c where c.user_name = a.user_name and c.equipment = 'clothing' ) as clothing ,(select eq_name from `test_game` d where d.user_name = a.user_name and d.equipment = 'shoe' ) as shoe from `test_game` a ?group by a.user_name;
2016-05-31
問題是怎么從右邊轉換為左邊,我自己的答案是:
select ?user_name,(select eq_name from `test_game` b where b.user_name = a.user_name and b.equipment = 'arms' ) as arms,(select eq_name from `test_game` c where c.user_name = a.user_name and c.equipment = 'clothing' ) as clothing ,(select eq_name from `test_game` d where d.user_name = a.user_name and d.equipment = 'shoe' ) as shoe from `test_game` a ?group by a.user_name;
感覺子查詢太多了,效率有點低,哪位大神幫忙優(yōu)化一下?