Skip to content

SUBSTRING

  • str: The original string from which a substring will be extracted.
  • pos: The starting position for extraction, with the first character in the string having the position of 1.
  • len: The length or number of characters to extract, starting from the position defined by pos.
SELECT SUBSTRING('Hello World', 1, 5) AS ExtractString;
+---------------+
| ExtractString |
+---------------+
| Hello |
+---------------+

The SUBSTRING function extracts a string from a given text field, starting at a certain position and for a certain length. In this example, it starts at position 1 and extracts 5 characters, resulting in the output ‘Hello’.