I have a database table which 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 being children of each other, 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 has status 0?
I know if there was a fixed depth then I could just do that many joins, and then use Min(status) to find out if any of them are set to 0, but I don't know how to do this having an undefined depth?
 
    