I’m really having a brain-fail on this one.
I have the following table:
id parentID name 1 0 Frank 2 1 Sally 3 1 John 4 3 Beth
I’d like a statement that selects only those items that have no children, so in the previous example:
Sally
Beth
Would be the result. Can’t seem to figure out a query to do this without creating a recursive function, which I don’t want do to if I can avoid.
Although less efficient (see: Left outer join vs NOT EXISTS), you could also do this with a left join: