Home  >  Article  >  Database  >  How to remove spaces in mysql

How to remove spaces in mysql

WBOY
WBOYOriginal
2021-12-27 18:04:5629671browse

Mysql method to remove spaces: 1. Use the replace() function to remove spaces in characters, the syntax is "replace(object,' ','')"; 2. Use the trim() function to remove the left and right characters spaces, the syntax is "trim('object')".

How to remove spaces in mysql

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

How to remove spaces in mysql

(1)mysql replace function

Syntax: replace(object,search,replace)

Meaning: Replace all occurrences of search in object with replace

Case:

Original data:

How to remove spaces in mysql

Repair statement:

update  t_user_score  set cname = REPLACE(cname ,' ','') ;

After repair:

How to remove spaces in mysql

(2) mysql trim function

Syntax:

Full format : TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)

Simplified format: TRIM([remstr FROM] str)

Returns the string str, in which all remstr prefixes and/or suffixes have been removed. If none of the classifiers BOTH, LEADIN or TRAILING is given, BOTH is assumed. remstr is optional and can remove spaces if not specified.

How to remove spaces in mysql

Recommended learning: mysql video tutorial

The above is the detailed content of How to remove spaces 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