Skip to main content
Version: V1.4.1

MID

Declaration​

MID(str,pos,len)

Description​

Returns a substring of str starting at pos and having a length of len. If any parameter is NULL, the function returns NULL.

  • If len is not specified, the substring starts at pos and extends to the end of str.

  • If pos is negative, the starting position is determined by counting backward from the end of str.

  • If len is less than or equal to 0, or if pos specifies an invalid starting position, an empty string is returned.

This function is an alias for SUBSTRING(str,pos,len).

Examples​

SELECT MID('OceanBase',6);
+--------------------+
| MID('OceanBase',6) |
+--------------------+
| Base |
+--------------------+
1 row in set (0.001 sec)