Select query for subcategories

  • Thread starter Thread starter Senna
  • Start date Start date
S

Senna

Hi all

Have a category and a item table like this:

CREATE TABLE #Category
(
ca_id INT PRIMARY KEY,
ca_parentid INT,
ca_name VARCHAR
)

CREATE TABLE #Item
(
it_id INT PRIMARY KEY,
it_ca_id INT,
it_name VARCHAR
)

If I now have a main category named Car then it can have
a subcategory named GM which can have a subcategory named
Saab and drilling down.
Now I need a query that can select every item from a
specific main category id and all its subcategories.

Any ideas?

Best regards / Senna
 
Back
Top