SQL to join one table to another table multiple times? (Mapping products to categories)

前端 未结 4 1977
北海茫月
北海茫月 2021-02-04 19:54

Let\'s say I have a Product, Category, and Product_To_Category table. A Product can be in multiple categories.

    Product             


        
4条回答
  •  孤街浪徒
    2021-02-04 20:21

    You can't create these results with a strict SQL query. What you're trying to produce is called a pivot table. Many reporting tools support this sort of behavior, where you would select your product and category, then turn the category into the pivot column.

    I believe SQL Server Analysis Services supports functionality like this, too, but I don't have any experience with SSAS.

提交回复
热议问题