直接上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 ;
效果不统一,值不对应了,求解
已解决问题