首页 新闻 会员 周边 捐助

mysql行转列

0
悬赏园豆:5 [已解决问题] 解决于 2015-07-02 15:50

直接上sql语句:

select * from orderinfo_view;

SET @EE='';
set @str_tmp='';
SELECT @EE:=CONCAT(@EE,'(IF(ColumnEnglishName=\'',ColumnEnglishName,'\'',',ColumValue,ColumValue)) AS ',ColumnEnglishName,',')
 as aa into @str_tmp FROM (SELECT DISTINCT ColumnEnglishName FROM orderinfo_view) A order by length(aa) desc limit 1; 
SET @QQ=CONCAT('SELECT custmerID,PlatformAccount,AddTime,Inspection_categoryID,serviceCost,ServiceName,ordercodeID,  ',
LEFT(@str_tmp,char_length(@str_tmp)-1),' FROM orderinfo_view GROUP BY ordercodeID');
PREPARE stmt  FROM @QQ; 
EXECUTE stmt ; 

效果不统一,值不对应了,求解

赶猪上架的主页 赶猪上架 | 初学一级 | 园豆:6
提问于:2015-06-12 12:45
< >
分享
最佳答案
0

已解决问题

赶猪上架 | 初学一级 |园豆:6 | 2015-07-02 15:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册