I have a database table that looks like this:
id | parent_id | status 1 | null | 1 2 | null | 0 3 | null | 1 4 | 2 | 1 5 | 4 | 1
So, as you can see, we have some categories that are children, and the depth is unlimited.
What I want to know is there an easy way to find out if any parents in a particular tree have status 0?
I know if there was a fixed depth, then I could just make so many connections and then use Min(status) to find out if any of them are set to 0, but I don't know how to do it if undefined depth?
source share