Help with sql statement.
I need help creating a sql statement. Given the below 2 tables. I am aware that this would have been easier if a subcategory table would have been created instead of stroring the categories and subcategories together.
Table Category
intID catParentID CatName
1 NULL Name 1
2 NULL Name 2
3 NULL Name 3
5 2 Name 4
7 2 Name 5
8 1 Name 6
Table Products
IntID catID ProductName
1 8 Prd 1
2 8 Prd 2
3 5 Prd 3
4 7 Prd 4
5 1 Prd 5
6 3 Prd 6
So if i select intID 1 from the Products table it will return catName 1 from the Category table
So if i select intID 2 from the Products table it will return catName 1 from the Category table
So if i select intID 3 from the Products table it will return catName 2 from the Category table
So if i select intID 4 from the Products table it will return catName 2 from the Category table
So if i select intID 5 from the Products table it will return catName 1 from the Category table
So if i select intID 6 from the Products table it will return catName 3 from the Category table