SUBSTRING(str,pos), SUBSTRING(str FROM pos), SUBSTRING(str,pos,len), SUBSTRING(str FROM pos FOR len) : SUBSTRING : String Functions MySQL TUTORIALS


MySQL TUTORIALS » String Functions » SUBSTRING »

 

SUBSTRING(str,pos), SUBSTRING(str FROM pos), SUBSTRING(str,pos,len), SUBSTRING(str FROM pos FOR len)


The forms without a len argument return a substring from string str starting at position pos.

The forms with a len argument return a substring len characters long from string str, starting at position pos.

If pos is a negative value, the beginning of the substring is from the end of the string.

The position of the first character is reckoned as 1.

If len is less than 1, the result is the empty string.

SUBSTR() is a synonym for SUBSTRING().

MID(str,pos,len) is a synonym for SUBSTRING(str,pos,len).

mysql> SELECT SUBSTRING('ABCDEFGHIJK',5);
+----------------------------+
| SUBSTRING('ABCDEFGHIJK',5|
+----------------------------+
| EFGHIJK                    |
+----------------------------+
row in set (0.00 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo String Functions
» SUBSTRING