mysql內建函式彙總

2021-07-04 15:10:30 字數 1690 閱讀 5749

mysql內建函式彙總

一.字串函式

select concat(name," age is ",age) from users;

insert(str,x,y,insert)//將字串x位置開始y個位置替換成insert

select lower(str) upper(str)

select * from users where upper(name)='wst';

select * from users where lower(name)='wst';

left(str,x) right(str,x)//分別返回左邊或者右邊的x個字元。

select left("abcedfg",3),right("abcdefg",3),left("abcdefg",null);

lpad(str,n,pad),rpad(str,len,padstr)//用字串pad對str最左邊或最右邊補到n位。

ltrim(str)

submit(str,x,y)//返回字串中得第x位置起,取y個字元。

二,數值函式

abs(x)//返回x的絕對值

ceil(x)//返回大於x的最小整數。

floor(x)//返回小於x的最大整數

`mod`(n,m)//返回n/y的模

rand()//0-1之間隨機數

round(x,d)//返回引數x的四捨五入的有y位小數的值

`truncate`(x,d)//返回數字x截斷y位小數的結果。

三。日期函式

用php的時間戳來完成。

select curdate();

select curtime();

select now();

select unix_timestamp(now());

select unix_timestamp(date);

select from_unixtime(1439711814);

select week(now());

select minute(curtime());

select date_format(now(),"%y-%m-%d %h:%i:%s");

四:流程控制函式

create table salary(

id int,

salary decimal(9,2)

);insert into salary values(1,10000);

select if(salary>3000,'height','low') from salary;

select case when salary<=300 then 'low' else 'height' end from salary;

五,其他函式

`database`();

version();//檢視資料庫當前版本

user();//檢視當前使用者

inet_aton(ip)//返回ip位址的網路位元組序

select `user`();

select version();

select password('123');

md5(str)//給**使用者加密

select * from mysql.`user`;

select `password`('*81f5e21e35407d884a6cd4a731aebfb6af209e1b');

Python內建函式彙總

函式名 abs delattr hash memoryview set all dict help min setattr any dir hex next slice ascii divmod id object sorted bin enumerate input oct staticmetho...

Python內建函式彙總

2 最大最小值 max 1,2,3 min 1,2,3 3 序列長度 len abc len 1,2,3 len 1,2,3 4 取模 divmod 5,2 2,1 5 乘方 pow 2,3,4 2 3 4 6 浮點數 round 1 2 型別判斷 isinstance x,list int 3 比...

Python內建函式彙總

abs 函式 返回數字的絕對值 divmod 函式 將除數和餘數運算結果進行結合 sum 函式 求和計算 round 函式 四捨五入 pow 函式 計算任意n次方值 min 函式 獲取最小值 max 函式 獲取最大值 hex 函式 十進位制轉換成十六進製制 oct 函式 十進位制轉換成八進位制 bi...