What are the string functions in MySQL
Editor to share with you what the string functions in MySQL are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
String function
1. Returns the ASCII code of the first character of the string s
SELECT ASCII ('AB');-returns the ASCII code value of A: 65
2. LENGTH/CHAR_LENGTH (s) / CHARACTER_LENGTH (s) returns the number of characters of the string s
SELECT LENGTH ('1234');-return 4
3. CONCAT (S1 ~ S2... Sn) string s1and other strings are merged into a single string
SELECT CONCAT ('hel','llo');-return hello
4. FIND_IN_SET (S1 ~ S2) returns the position of the string that matches S1 in the string S2
SELECT FIND_IN_SET ("c", "arecrum bregory credpene");-return 3
5. The FORMAT (xQuery n) function can format the number x into "#, #. # #", keeping x to n places after the decimal point, and rounding the last digit.
SELECT FORMAT (250500.5634, 2);-returns 250500.56
6. INSERT (S1, x, rep, Len2) string S2 replaces the x position of S1, starting with a string of length len
SELECT INSERT ("google.com", 1, 6, "runnob");-returns runoob.com
7. LOCATE (S1 ~ s) gets the starting position of S1 from the string s
SELECT LOCATE ('st','myteststring');-return 5
8. LCASE (s) / LOWER (s) changes all letters of the string s to lowercase letters
SELECT LOWER ('RUNOOB');-return runoob
9. UCASE (s) / UPPER (s) changes all letters of the string s to uppercase letters
SELECT UCASE ('runoob');-return RUNOOB
10. TRIM (s) removes the spaces at the beginning and end of the string s
SELECT TRIM ('RUNOOB');-return RUNOOB
11. LTRIM (s) removes the space at the beginning of the string s
SELECT LTRIM ('RUNOOB');-return 'RUNOOB'
12. RTRIM (s) removes the space at the end of the string s
SELECT RTRIM ('RUNOOB');-return' RUNOOB'
13. SUBSTR (s, start, length) truncates a substring of length length from the start position of the string s
SELECT SUBSTR ("RUNOOB", 2,3) AS ExtractString;---- intercepts 3 characters from the second position in the string RUNOOB and returns UNO
14. SUBSTR/SUBSTRING (s, start, length) truncates a substring of length length from the start position of the string s
SELECT SUBSTR/SUBSTRING ("RUNOOB", 2,3);-truncate 3 characters from the second position in the string RUNOOB and return UNO
15. POSITION (S1 IN s) gets the starting position of S1 from the string s
SELECT POSITION ('b' in 'abc');-return 2
16. REPEAT (sQuery n) repeat the string s n times
SELECT REPEAT ('runoob',3);-return runoobrunoobrunoob
17. REVERSE (s) reverses the order of the string s
SELECT REVERSE ('abc');-return cba
18. STRCMP (S1 and S2) compare the strings S1 and S2, return 0 if S1 and S2 are equal, if S1 > S2 return 1, if S1