0% found this document useful (0 votes)
4 views7 pages

DOC-20240331-WA0009.

Electricity

Uploaded by

soumyaprksh16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

DOC-20240331-WA0009.

Electricity

Uploaded by

soumyaprksh16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Functions and Operations in MYSQL

MySQL offers a rich set of functions and operations to manage and manipulate data

within your relational database. These functions fall into various categories depending

on the type of data they handle or the operation they perform. Here's a breakdown of

some common MySQL functions and operations:

Data Manipulation Functions:

● Numeric Functions: Perform calculations on numbers. Examples include

ROUND(), MIN(), MAX(), and mathematical functions like EXP() or PI().

● String Functions: Work with text data. Examples include CONCAT() for joining

strings, SUBSTRING() for extracting parts of a string, and functions for changing

case (UPPER(), LOWER()).

● Date and Time Functions: Handle date and time data. Examples include

CURDATE() for getting the current date, ADDDATE() to add an interval to a date,

and functions for extracting specific parts like year or hour.

Comparison and Logical Operators:

● Comparison Operators: Compare values. These include =, >, <, >=, and <= for

numeric and string comparisons.

● Logical Operators: Combine conditions. These include AND, OR, and NOT to build

complex logical expressions in your queries.

Control Flow Functions:

● IF Function: Executes code conditionally based on a boolean expression. Useful

for making decisions within your queries.


Aggregate Functions:

● Perform calculations on entire groups of data. Examples include COUNT() to get

the number of rows, SUM() to add values in a column, and AVG() to calculate the

average.

Other Functions:

● There are many other specialized functions for data conversion (CAST()), user

information (USER()), and even full-text search functionalities.

Operations:

● Data Retrieval: The SELECT statement is fundamental for fetching data from

tables based on specific criteria.

● Data Insertion: The INSERT statement adds new rows of data to a table.

● Data Update: The UPDATE statement modifies existing data in a table.

● Data Deletion: The DELETE statement removes rows from a table.

● Data Filtering: The WHERE clause is used within SELECT, UPDATE, and DELETE

statements to specify conditions for filtering data.

● Joining Tables: Combine data from multiple tables based on relationships.

This is just a glimpse into the vast functionality of MySQL. By effectively using functions

and operations, you can manage your database efficiently, perform complex data

manipulations, and retrieve the information you need.

Procedure to create database and table in MYSQL


What is the query ? How to sort and filter

A query is a request for data or information from a database. It is a structured

command used to retrieve, insert, update, or delete data from one or more database

tables. Queries are written in a database query language such as SQL (Structured Query

Language) for relational databases like MySQL, PostgreSQL, SQL Server, etc.

To sort and filter data using a query, you can use the SELECT statement along with the

ORDER BY and WHERE clauses.

Here's how you can do it:


Sorting Data:

​ You can sort data in ascending or descending order based on one or more

columns using the ORDER BY clause.

Syntax:

SELECT column1, column2, ...

FROM table_name

ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...;

Example:

sql

SELECT * FROM users

ORDER BY username ASC; -- Sorting usernames in ascending order

Filtering Data:

​ You can filter data based on specified conditions using the WHERE clause.

Syntax:

​ sql

​ Copy code

SELECT column1, column2, ...

FROM table_name

WHERE condition;
​ Example:

​ sql

​ Copy code

SELECT * FROM users

WHERE age > 18; -- Retrieving users older than 18

Combining Sorting and Filtering:

​ You can combine sorting and filtering in the same query to retrieve sorted

and filtered data.

Syntax:

​ sql

​ Copy code

SELECT column1, column2, ...

FROM table_name

WHERE condition

ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...;

​ Example:

​ sql

​ Copy code

SELECT * FROM users

WHERE country = 'USA' AND age > 30


ORDER BY last_name ASC; -- Retrieving users from the USA older than 30, sorted by

last name

Remember to replace column1, column2, table_name, and conditions with appropriate

column names, table names, and filtering conditions specific to your database

schema and requirements.

By using these techniques, you can effectively sort and filter data to retrieve

the desired information from your database using queries.

You might also like