Home  >  Article  >  Database  >  Commonly used built-in functions in mysql

Commonly used built-in functions in mysql

小云云
小云云Original
2018-03-15 10:56:241755browse

This article mainly shares with you the commonly used built-in functions in MySQL, including aggregate functions, mathematical functions, string functions, etc. I hope it can help you.

1. Aggregation function

  • COUNT() function: for any parameter except (*), Returns the number of rows in the selected collection that are not null values. For the parameter (*), returns the number of all rows in the collection, including rows with null values. . count(*) without WHERE is internally optimized by mysql and can return record parameters faster

  • SUN( ) Function: Find the sum of the values ​​of a certain field in the table

  • AVG() Function: Find the value of a certain field in the table The average value

  • MAX()Function: Find the maximum value of a field in the table

  • MIN()Function: Find the minimum value of a field in the table


2. Mathematical function

  • ABS()Function: Find the absolute value of a field in the table

  • FLOOR()Function: Returns the largest integer less than or equal to parameter x

  • RAND()Function: Returns a random number between 0~1

  • TRUNCATE(x,y)Function: Returns the value of x retained to y digits after the decimal point

  • SQRT(x)Function : Find the square root of parameter x


3, string function

  • UPPER(s)andUCASE(s)Function: Convert all letters in string s to uppercase letters

  • LEFT(s,n)Function: Return The first n characters of string x

  • ##SUBSTRING(s,n,len)Function: Starting from the nth position of s, get the string


4. Date and time parameters

  • CURDATE() and CURRENT_DATE() Function: used to get the current date

  • CURTIME() and CURRENT_TIME() Function: used to get the current time

  • NOW() and CURRENT_TIMESTAMP() Functions: Get the current date and time


5. Other functions

  • IF(expr,v1,v2)Function: Indicates that if the expression expr is true, v1 will be executed, otherwise v2 will be executed. (Similar to Sanmu Budget)

  • IFNULL(expr,v2)Function: Indicates that if expr is not empty, return the value of the expression, otherwise return v2

  • VERSION()Function: Get the version number information of the system

Related recommendations:


PHP implementation does not use built-in functions to implement the string conversion method

Detailed explanation on the usage of JavaScript built-in function console

php Basic usage of built-in functions

The above is the detailed content of Commonly used built-in functions in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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