溫馨提示×

怎么在mysql中截取字符串

養魚的貓咪
418
2021-04-23 08:05:24
欄目: 云計算

mysql中截取字符串的方法:1.使用left函數從左邊截取字符串;2.使用right函數從右邊截取字符串;3.使用substring函數在指定位置截取字符串;

怎么在mysql中截取字符串

具體方法如下:

1.left函數

mysql中left函數的作用是用于返回具有指定長度字符串的左邊部分。

left函數語法:

left(str, length);

參數:

str:指定字符串。

length:需截取字符的長度。

left函數使用方法:

select left('helloworld',5) as result from dual;     //返回 hello

2.right函數

mysql中right函數的作用是用于返回具有指定長度字符串的右邊部分。

right函數語法:

right(str, length);

參數:

str:指定字符串。

length:需截取字符的長度。

right函數使用方法:

select right('helloworld',5) as result from dual;     //返回 world

3.substring函數

mysql中substring函數的作用是用于從字符串中提取子字符串。

substring函數語法:

substring(str, pos, length);

參數:

str:指定字符串。

pos:指定截取位置。

length:需截取字符的長度。

substring函數使用方法:

select substring('helloworld',5,4) as result from dual;     //返回 worl


0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女