Skip to content
Advertisement

how i can get all products from parentid in SQL Server?

I have a category table to name TBL_category And includes the following fields:

nid i identity field

and i have a production Table TBL_Productions and foreign key is to nid And includes the following fields:

productid is identity

My question is:

How can I display all products, when user selected mobile category ?

I have nothing to do with the subcategories, I want all products to be displayed when the mobile or tablet category is selected.

thanks

Advertisement

Answer

One option uses a recursive query to recover the “mobile” category and all of its descendants, and then brings the products table with a join:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement