Home>Article>Database> How to use built-in functions in MySQL and PHP

How to use built-in functions in MySQL and PHP

WBOY
WBOY forward
2023-05-27 08:46:05 1169browse

MySQL built-in functions

MySQL built-in functions can help us process data in the table more conveniently and simplify operations.

How to use built-in functions in MySQL and PHP

Mathematical functions:

##ABS() Take absolute Value SQRT() Take the root MOD() Take the modulo FLOOR() Returns the largest integer value that is not greater than CELLING() Returns is not less than The smallest integer value ROUND() Rounding SIN() Take the sine COS() Get cosine ##String function:
Function Description

Function ##LENGTH() Get the length of the string LOWER() Convert all strings to lowercase UPPER() Convert all strings to Capitalize TRIM() Remove both ends, prefix or suffix REPLACE() Replace string Date time function:
Description

Function Description NOW() Get the current time and date CURDATE() Get the current date CURTIME() Get the current time YEAR() Get the year MONTH() Get the month DAY() Get the day date_format() Convert time format Aggregation function:

Function Description COUNT() Count the number of rows MAX() Get the maximum value MIN() Get the minimum value SUM () Get the accumulated value Conditional judgment function:

Function Description IF IF IFNULL IF NULL CASE WHEN Conditional judgment Example 1
Check how many files exist in the table Piece of data:

Output result:

Server connection successful!

SQL statement executed successfully!
Array

(
[count(*) ] => 5
)


##Example 2

How to use built-in functions in MySQL and PHPGet the highest salary:

Output result:

Server connection successful!

SQL statement executed successfully!

Array
(

[max(salary)] => 30000.00
)

The above is the detailed content of How to use built-in functions in MySQL and PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete