And it has nothing to do with PHP, per se. The query will do what you want by itself and could be used standalone, with PHP, with ASP, with JSP, etc., etc.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.