Select query for subcategories

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top