sql query

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi all !

Tell me please, how can I write a SQL query that will give me a list of all Products, Product Names, Article, Description, and all characteristics by columns:
Name  |   Article |  Description |  Attribute_1  |   Attribute_2  |  Attribute_3  |   ...  |   etc
3 years ago
Have a look at the existing Stored procedure in the database
ProductLoadAllPaged
3 years ago
Here's a basic query
select p.Id, p.Name, psam.*, sao.*
from Product p
left join Product_SpecificationAttribute_Mapping psam on psam.ProductId = p.Id
left join SpecificationAttributeOption sao on sao.Id = psam.SpecificationAttributeOptionId
left join SpecificationAttribute sa on sa.Id = sao.Id


Here's a more complex answer
https://www.nopcommerce.com/en/boards/topic/46538/sample-sql-query-product-stock-by-attributes

In either case, you need to do a PIVOT if you expect the rows to be columns for
|  Attribute_1  |   Attribute_2  |  Attribute_3  |   ...  |
3 years ago
Many thanks you all. Problem solved.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.