Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert string case in MySQL

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

MySQL how to convert string case, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

How to convert the case of MySQL string

There are two pairs of deMySQL string case conversion functions: lower (), uppper () and lcase (), ucase ()

Selectucase ('ddd'); +-+ | ucase (' ddd') | +-+ | DDD | +-+

Normally, I choose lower (), upper () to convert string case because this is compatible with functions in other databases.

How to clear the leading and trailing spaces of a string by MySQL

There are three functions to clear the leading and trailing spaces of MySQL strings in MySQL: ltrim (), rtrim (), and trim ().

Selectconcat ('.', trim ('ddd'),'.) +-- + | concat ('.', trim ('ddd'),'.) | +-+ | .ddd. | +-+

The trim string function in MySQL is really powerful. It can eliminate not only the spaces at the beginning and end of the string, but also any character we specify. Ltrim (), rtrim () is just a subset of its functions. Take a look at the complete syntax of the trim function:

Trim ([{both | leading | trailing} [remstr] from] str) 2.trim ([remstrfrom] str)

1. Clears the first character of the MySQL string.

Selecttrim (leading'.'from'..ddd..') +-- + | trim (leading'.'from'..ddd..') | +-- + | ddd.. | +-+

two。 Clears the trailing character of the string.

Selecttrim (trailing'.'from'..ddd..') +-- + | trim (trailing'.'from'..ddd..') | +-- + | .ddd | +-- +

3. Clears the characters at the beginning and end of the string.

Selecttrim ('. 'from'..ddd..'); +-- + | trim ('. 'from'..ddd..') | +-+ | ddd | +-+

Trim () clears the space at the beginning and end of the MySQL string by default.

After reading the above, have you mastered how to convert the case of a string in MySQL? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report