MySQL SUBSTRING Function Guide

In MySQL, the SUBSTRING function is used to extract a substring from a string. Its basic syntax is as follows:

SUBSTRING(str, start, length)

Among them:

  1. “str is the original string from which the substring will be extracted.”
  2. The start parameter is the position from which to extract the substring (starting from 1).
  3. Length is the length of the substring to be extracted.

For example, to extract 5 characters starting from the 3rd character in a string, you can use the following query:

SELECT SUBSTRING('Hello World', 3, 5);

This will return llo W.

bannerAds