Skip to content

MID

  • str: The original string from which a substring is to be extracted.
  • pos: The starting position where the extraction of a substring should begin. The position starts from 1 in MySQL.
  • len: The length of the substring that is to be extracted. This specifies the number of characters from the starting position (pos) to be included in the substring.
SELECT MID('SQL Documentation', 5, 11) AS ExtractString;
+----------------+
| ExtractString |
+----------------+
| Documentation |
+----------------+

In the example, the MID function is being used to extract a substring from the string ‘SQL Documentation’, starting from the 5th position and the length of the substring is 11 characters. The output, ‘Documentation’, is the extracted substring.