MySQL functions are built-in operations that perform calculations or manipulations on data. Functions can be used to:
Function | Description | Example |
---|---|---|
COUNT() |
Counts rows matching criteria |
SELECT COUNT(*) FROM employees;
|
SUM() |
Sums values in a column |
SELECT SUM(salary) FROM employees;
|
AVG() |
Calculates average value |
SELECT AVG(salary) FROM employees;
|
NOW() |
Returns current date and time |
SELECT NOW();
|
UPPER() |
Converts string to uppercase |
SELECT UPPER(first_name) FROM employees;
|
-- Count total employees SELECT COUNT(*) AS total_employees FROM employees; -- Find average salary SELECT AVG(salary) AS avg_salary FROM employees; -- Show names in uppercase SELECT UPPER(first_name) AS uppercase_name FROM employees;
Use functions to make your queries more powerful and insightful!
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!