Get the App
SLTechnology News&Howtos  ›  Database  › 

How to remove spaces in mysql

Shulou Source: shulou.com Published: 2022-05-31 12:19:14 11月13日 Update

Xiaobian to share with you how mysql to remove spaces, I hope you have something to gain after reading this article, let's discuss it together!

mysql methods to remove spaces: 1, use replace() function to remove spaces in characters, syntax is "replace(object,','')";2, use trim() function to remove spaces around characters, syntax is "trim ('object')".

Operating environment of this tutorial: Windows 10 system, mysql version 8.0.22, Dell G3 computer.

(1) The mysql replace function

syntax: replace(object,search,replace)

Meaning: Replace all search occurrences in object with replace

Case:

Original data:

Fix statement:

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

After repair:

(2) The mysql trim function

Grammar:

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

Simplified format: TRIM([remstr FROM] str)

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

After reading this article, I believe you have a certain understanding of "mysql how to remove spaces". If you want to know more about it, welcome to pay attention to the industry information channel. Thank you for reading!

Tags: Spaces functions grammars characters formats articles prefixes suffixes strings done situation meaning tutorials data methods more cases versions environments computers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker MariaDB Shulou Technology Apple