Use LOG10 and LOG2
/* mysql> select LOG10(10); +-----------+ | LOG10(10) | +-----------+ | 1 | +-----------+ 1 row in set (0.00 sec) mysql> select LOG2(8); +---------+ | LOG2(8) | +---------+ | 3 | +---------+ 1 row in set (0.00 sec) */ select LOG10(10); select LOG2(8);