MySQL functions perform specific operations on data, making queries more efficient and flexible. They are categorized into aggregate, string, date, and mathematical functions.
Common Uses of MySQL Functions
- Aggregate Functions: Summarize data (e.g.,
SUM()).
- String Functions: Modify text (e.g.,
CONCAT()).
- Date Functions: Manipulate dates (e.g.,
NOW()).
- Mathematical Functions: Perform calculations (e.g.,
ROUND()).
- JSON Functions: Handle JSON data (e.g.,
JSON_OBJECT()).
Examples
- Aggregate Function
Explanation: Calculates the average salary of employees.
- String Function
Explanation: Converts customer names to uppercase.
- Date Function
Explanation: Retrieves the current date.
- Mathematical Function
Explanation: Rounds the price to two decimal places.
- JSON Function
Explanation: Converts id and name columns into a JSON object.
MySQL functions perform specific operations on data, making queries more efficient and flexible. They are categorized into aggregate, string, date, and mathematical functions.
Common Uses of MySQL Functions
SUM()).CONCAT()).NOW()).ROUND()).JSON_OBJECT()).Examples
Explanation: Calculates the average salary of employees.
Explanation: Converts customer names to uppercase.
Explanation: Retrieves the current date.
Explanation: Rounds the
priceto two decimal places.Explanation: Converts
idandnamecolumns into a JSON object.