How to convert string case in MySQL
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!