通过sql case when对商品表自己定义属性进行查询。实现行专列效果。
declare @sql varchar(8000) set @sql='select StyleNo' select @sql=@sql+','+[A_GoodsAttr].AttrName+'=isnull(max(case AttrName when '''+[A_GoodsAttr].AttrName+''' then AttrValue end),0)' from A_GoodsAttr order by AttrId set @sql=@sql+' from A_ProAttrList where 1=1 and StyleNo=''100010'' group by StyleNo order by StyleNo' print @sql exec(@sql)
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5058905.html,如需转载请自行联系原作者 |