String function
Function | Function |
---|---|
CONCAT(s1,s2,....) | String connection |
INSERT(str,x,y,instr) | Replace the string from the specified start tag to the end with the specified string |
LOWER(str) | Convert all characters of the string to lowercase |
UPPER(str) | Convert all strings to uppercase |
LEFT(str,x) | Return the leftmost x characters of string str |
RIGHT(str,x) | Return the rightmost x characters of string str |
LPAD(str,n,pad) | Fill n pads on the leftmost side of str |
Fill n pads on the rightmost side of str | |
Remove the spaces on the left side of the string str | |
Remove the spaces on the right side of the string str | |
Return str to repeat x The result of times | |
Compare strings s1 and s2 | |
Replace all occurrences of string a in string str with string b | |
Remove the end of the string line and spaces at the beginning of the line | |
Returns a string with a length of y characters starting from the x position of the string str |
Mathematical function
Function | |
---|---|
Returns the absolute value of x | |
Returns the absolute value greater than x Minimum integer value | |
Returns the maximum integer value less than x | |
Returns the modulus of x/y | |
Returns a random value between 0 and 1 | |
Returns the rounded value of parameter x with y decimal places | |
Return the result of number x truncated to y decimal places |
Date and time functions
Function | |
---|---|
Return the current date | |
Return the current time | |
Return the current date and time | |
Returns the UNIX timestamp of date date | ##FROM_UNIXTIME |
WEEK(date) | |
##YEAR(date) | |
HOUR(time) | |
MINUTE(time) | |
MONTHNAME(date) | |
##DATE_FORMAT( date,fmt) | Returns the date value in string fmt format |
DATE_ADD(date,interval expr type) | Returns a date or time Value plus the time value of a time interval |
DATEDIFF(expr,expr2) | Returns the number of days between the start time expr and the end time expr2 |
Process function |
Function
IF(value,t f) | |
---|---|
IFNULL(value1,value2) | If value1 is not empty, return value1, otherwise return value2 |
CASE WHEN [value1] THEN[result1]...ELSE[default]END | If value1 is true, return result1, otherwise return result |
CASE[expr] WHEN [value1]THEN[result1]...ELSE[default]END | If expr is equal to value1, return result1, otherwise return default |
Other commonly used functions |
#Function
##DATEBASE() | |
---|---|
VERSION() | Return the current database version |
USER() | Return the current login username |
INET_ATON(ip) | Returns the numerical representation of the ip address |
INET_NTOA(num) | Returns the numerical representation of the ip address |
PASSWORD(str) | Returns the encrypted version of the string str |
MD5() | Returns characters The md5 value of string str |
Recommended tutorial: " | MySQL Tutorial | "
The above is the detailed content of Complete list of commonly used functions in MySQL. For more information, please follow other related articles on the PHP Chinese website!