Complete list of commonly used functions in MySQL

Guanhui
Release: 2020-05-07 10:54:11
forward
1941 people have browsed it

String function

##RPAD(str,n,pad) Fill n pads on the rightmost side of str LTRIM(str) Remove the spaces on the left side of the string str RTRIM(str) Remove the spaces on the right side of the string str REPEAT(str,x) Return str to repeat x The result of times STRCMP(s1,s2) Compare strings s1 and s2 REPLACE(str,a ,b) Replace all occurrences of string a in string str with string b TRIM(str) Remove the end of the string line and spaces at the beginning of the line SUBSTRING(str,x,y) Returns a string with a length of y characters starting from the x position of the string str
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

Mathematical function

Function Function ABS(x) Returns the absolute value of x CEIL(x) Returns the absolute value greater than x Minimum integer value FLOOR(x) Returns the maximum integer value less than x MOD(x,y) Returns the modulus of x/y RAND() Returns a random value between 0 and 1 ROUND(x,y) Returns the rounded value of parameter x with y decimal places TRUNCATE(x,y) Return the result of number x truncated to y decimal places

Date and time functions

Function Function ##CURDATE() CURTIME() NOW() UNIX_TIMESTAMP(date) ##FROM_UNIXTIME Returns the date value of UNIX timestamp WEEK(date) Returns the date as the week of the year Return the year of date Return the hour value of time Return the minute value of time Return the month name of 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
Return the current date
Return the current time
Return the current date and time
Returns the UNIX timestamp of date date
##YEAR(date)
HOUR(time)
MINUTE(time)
MONTHNAME(date)

Function

Function IF(value,t f) If value is true, return t; otherwise return 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

Function Returns the current database name Recommended tutorial: " "
##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
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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!