通过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)
1、所有商品自己定义属性
2、单货号自己定义属性
|