Use the trim function in MYSQL syntax to delete characters on both sides

Source: Internet
Author: User
Tags mysql manual


In actual development, you always encounter this situation.
Www.2cto.com or when there is too much data in this case, it will make you crazy. If you still use select fields from table where like '/%', it is definitely a thankless approach, then, taking a closer look at the built-in functions of MYSQL is definitely the first priority. I first thought that the trim in the PHP function may also be used in mysql. The answer is yes. You can find it in the MYSQL manual. Of course, you can refer to Baidu. What I am talking about below is the same as that of my predecessors. Www.2cto.com [SQL]
SELECT *, trim (LEADING '/' FROM 'path') as paths FROM 'ts _ back_pic 'limit 10 grand introduction to the first, LEADING, you can delete the specified character on the left and the string [SQL] SELECT *, trim (TRAILING '/' FROM 'path') as paths FROM 'ts _ back_pic 'limit 10 second, you can delete specified characters and strings on the right.
Www.2cto.com
[SQL] SELECT *, trim (BOTH '/' FROM 'path') as paths FROM 'ts _ back_pic 'limit 10 third, you can delete specified characters and strings on BOTH sides
Most importantly, trim deletes multiple characters in a PHP function, in MYSQL, the deletion is a simple [SQL] SELECT *, trim ('path') as paths FROM 'ts _ back_pic 'limit 10; delete spaces on BOTH sides to form a comprehensive sequence of [SQL] SELECT *, trim (BOTH '\ r \ n' FROM trim ('path ')) as paths FROM 'ts _ back_pic 'limit 10; Environment: enter a space and then press enter to delete the space + press ENTER
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.