Factorial in SQL

Example for versions MySQL 3.23.57

Replace TABLE with name of any table you have access to, like mysql.help_topic.

select concat(cast(t2.n as char), "! = ",  cast(exp(sum(log(t1.n))) as char))
  from 
  ( select @i := @i+1 AS n
      from TABLE, (select @i := 0) as sel1
      limit 16 ) t1,
  ( select @j := @j+1 AS n
      from TABLE, (select @j := 0) as sel1
      limit 16 ) t2
 where t1.n <= t2.n
 group by t2.n