Select products where the category belongs to any category in the hierarchy

前端 未结 9 1650
再見小時候
再見小時候 2021-02-06 05:39

I have a products table that contains a FK for a category, the Categories table is created in a way that each category can have a parent category, example:

Compu         


        
9条回答
  •  青春惊慌失措
    2021-02-06 06:14

    My answer to another question from a couple days ago applies here... recursion in SQL

    There are some methods in the book which I've linked which should cover your situation nicely.

提交回复
热议问题