4. MYSQL common functions (string)

Table of contents

 

abs(x): returns the absolute value of x

ceil(x): returns the smallest integer greater than x

floor(x): Returns the largest integer less than x

 mod(x,y): returns the modulus of x/y

 Rand(): returns a random number from 0 to 1

 round(x): Returns the value of x with y decimal places after rounding

 truncate(x, y): returns the result of x truncated to y decimal places


abs(x): returns the absolute value of x

select ABS(-0.8) ,ABS(0.8);

ceil(x): returns the smallest integer greater than x

select CEIL(-0.8),CEIL(0.8);

floor(x): Returns the largest integer less than x

 select FLOOR(-0.8), FLOOR(0.8);

 mod(x,y): returns the modulus of x/y

select MOD(15,10),MOD(1,11),MOD(NULL,10);

 Rand(): returns a random number from 0 to 1

select RAND(),RAND();

 

 

select ceil(100*rand()),ceil(100*rand());

 round(x): Returns the value of x with y decimal places after rounding

 select ROUND(1.1),ROUND(1.1,2),ROUND(1,2);

 truncate(x, y): returns the result of x truncated to y decimal places

 select ROUND(1.235,2),TRUNCATE(1.235,2);

Guess you like

Origin blog.csdn.net/weixin_62190821/article/details/128485229
Recommended