They even mention CTEs at the bottom of the article, but just as a throwaway idea. I'm not too familiar with them in MySQL, but they're the obvious choice for doing something like this with other databases.
Sigh. Fucking kids on my lawn.
Sigh. Fucking kids on my lawn.