What is the method for truncating strings in MySQL?

In MySQL, you can use the SUBSTRING function to extract a substring.

Syntax:
SUBSTRING(str, start, length)

Explanation of parameters:

  1. String: The string to be extracted.
  2. Start: The position at which the extraction begins (starting position is 1)
  3. length: the desired length to be cut

Assuming there is a string “Hello, World!”, and we want to extract the part “World”.

Choose only the characters starting from the 8th position in the string “Hello, World!” and take the next 5 characters.

The result is “World”.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds