Is there a simple way to query all the categories from a self referencing table that contains categories and sub categories all in the same table. Similar to book categories on Amazon.com. For example, a set of related categories could be: Books->Computers->Programming->T_SQL
The table being defined like
PK_CAT_ID int NOT NULL
PARENT INT ( references PK_CAT_ID or NULL )
CATEGORY_NAME CHAR NOT NULL
The data being:
1, NULL, Books
2, 1, Computers
3, 2, Programming
4, 3, T_SQL
Find all parents of T_SQL category.
The table being defined like
PK_CAT_ID int NOT NULL
PARENT INT ( references PK_CAT_ID or NULL )
CATEGORY_NAME CHAR NOT NULL
The data being:
1, NULL, Books
2, 1, Computers
3, 2, Programming
4, 3, T_SQL
Find all parents of T_SQL category.