OK this is getting confusing so I decided to write a new question.
I need to check if a row in my category table is a child category. I then need to check which parent category the child is part of?
A parent category has a categoryID and a ParentCategoryID of 0
A child category has a categoryID and a ParentCategoryID eg 30.
Category Table:
ID PCID NAME
10 0 Computers
11 10 Software
12 10 Hardware
This is what Ive tried:
This will display the parent categories(because PCID 0 is the parent):
SELECT CategoryID, ParentCategoryID, Name, Published, Deleted, PictureID
FROM Nop_Category
WHERE (Deleted = 0)
AND (Published = 1)
AND (ParentCategoryID = 0)
Self join back to the table to find the actual parent of child.
This would return both children of the category “Computers”. Is that what you’re looking for?
Of course, you can turn this around to display all the children of a specific parent or from all parents:
Or, if you just want the children of category “Computers”, change your ParentCategoryId to 10