Home >Database >Mysql Tutorial >How to remove the first character in mysql

How to remove the first character in mysql

WBOY
WBOYOriginal
2022-05-19 10:21:346738browse

Method: 1. Use the right function, the syntax is "update table name set specified field = right (specified field, length (specified field)-1)..."; 2. Use the substring function, the syntax is "select substring(specified field,2)..".

How to remove the first character in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to remove the first character in mysql

MySQL string interception related functions:

1. Intercept the string starting from the right

right(str, length)

Description: right (truncated field, truncated length)

Example:

select right(content,200) as abstract from my_content_t

Remove the first character of the specified field”

update 表名 set 指定字段 = right(指定字段, length(指定字段)-1) WHERE 指定字段 like '"%';

2, Intercept string

substring(str, pos)
substring(str, pos, length)

Description: substring (intercepted field, starting from which number to intercept)

substring (intercepted field, starting from which number to intercept, intercepting length)

Example:

select substring(content,5) as abstract from my_content_t
select substring(content,5,200) as abstract from my_content_t

(Note: If the number of digits is a negative number such as -5, it is the length from the last digit to the end of the string or interception)

Recommended Learning: mysql video tutorial

The above is the detailed content of How to remove the first character in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn