Hi again!
The query below uses quite a bit of strange looking SQL syntax:
select all
count(1) minus
union all
select 1 only
order by 1 limit 1 ;
+-------+
| minus |
+-------+
| 1 |
+-------+
1 row in set (0.00 sec)
The “ALL” in the “SELECT ALL” is actually the default – so you hardly ever see it.
“COUNT(1)” is mostly used with Oracle, where it may have a performance benefit over “COUNT(*)”. The result however is the same than “COUNT(*)”.
The “minus” and “only” are column aliases.
Last but not least, the “ORDER BY 1″ means, that we order by the first column.
Below the same slightly more readable:
select
count(*) as cnt
union all
select 1
order by cnt limit 1 ;