I\'ve got a sort of tree like thing going on in my MySQL database.
I have a database that has categories, and each category has a subcat. I\'m keeping all the catego
But if I had like 10 categories under Toys, then I'd have to do this join and query 10 times. Is there a better way to handle this?
Yes, there's a way of storing data called "nested sets". It's a bit harder to insert the data, but simple to select an entire, multi-level branch using a single select statement.
Also, Celko has written a book about this subject, with a chapter about nested sets and other chapters about other methods.