Mega Code Archive

 
Categories / MySQL / Math
 

Use TRUNCATE

/* TRUNCATE function simply returns the supplied value X truncated to the  number of decimal places equal to the supplied value D */ select TRUNCATE(113, -2); select TRUNCATE(113, -1); /* mysql> select TRUNCATE(113, -2); +-------------------+ | TRUNCATE(113, -2) | +-------------------+ |               100 | +-------------------+ 1 row in set (0.00 sec) mysql> select TRUNCATE(113, -1); +-------------------+ | TRUNCATE(113, -1) | +-------------------+ |               110 | +-------------------+ 1 row in set (0.00 sec) */