DQL Command in SQL

DQL stands for Data Query Language, and it is a subset of SQL commands that allows you to retrieve data from one or more tables in a database. DQL commands are used to perform operations such as selecting, filtering, sorting, grouping, and aggregating data from tables. The most common DQL command is:

SELECT: This command is used to retrieve data from one or more tables. You can use various clauses such as WHERE, GROUP BY, HAVING, ORDER BY, and LIMIT to filter, aggregate, sort, and limit the results. The syntax of the SELECT command is:

SELECT column1, column2, … FROM table1
[WHERE condition]
[GROUP BY column1, column2, …]
[HAVING condition]
[ORDER BY column1, column2, … [ASC|DESC]]

For example, if you want to select the name and email of all the employees who work in the sales department and order them by name in ascending order, you can use the following query:

SELECT name, email FROM employee
WHERE department = 'sales'
ORDER BY name ASC;

This query will return a result set like this:

nameemail
Alicealice@company.com
Bobbob@company.com
Carolcarol@company.com
Scroll to Top