Summary of mysql commonly used string functions

Summary of commonly used string functions

name Features
lower(column str) String to lowercase
upper(column str) Convert string to uppercase
concat(column str, column str, …) Concatenated string
concat_ws(separator, column str, column str, …), Specified splicing character splicing string
substr(str, pos[, length]) Returns a substring of the string, pos index starts from 1, and length is not specified to the end
substring(str, pos[, length]) Same as above, index starts from 1
left(str, length) Intercept the substring of the specified length on the left
right(str, length) Intercept the substring of the specified length on the right
length(str) Get the byte length of a string
char_length(str) Character length of the string
instr(str, substr) Returns the index position of the substring in the string, if not found, it returns 0
lpad(str, length, padstr) Left padding
rpad(str, length, padstr) Right fill
trim( [substr from] str ) Remove the specified substring at the beginning and end of the string, the default substring is a space
ltrim([substr from] str) Remove the specified substring on the left side of the string, the default substring is a space
rtrim([substr from] str) Remove the specified substring on the right side of the string, the default substring is a space
replace(str, from_str, to_str) Replace all matched substrings
format(x , D[, local]) Format the number x, which can be used to intercept the number of decimal places, round up, etc.
space(N) Return a substring consisting of N spaces
repeat(str, count) Return a string composed of repeated string count times
reverse(str) Reverse string
strcmp( str1, str2 ) Compare two strings, greater than return 1; equal to return 0; less than return -1

Guess you like

Origin blog.csdn.net/giantleech/article/details/114213349