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 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:
name | |
Alice | alice@company.com |
Bob | bob@company.com |
Carol | carol@company.com |