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

How to remove the first character in mysql

WBOY
Release: 2022-05-19 10:21:34
Original
6679 people have browsed it

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)
Copy after login

Description: right (truncated field, truncated length)

Example:

select right(content,200) as abstract from my_content_t
Copy after login

Remove the first character of the specified field”

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

2, Intercept string

substring(str, pos)
substring(str, pos, length)
Copy after login

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
Copy after login

(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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template