🔍 Data Query Language (DQL)

Last Updated: 7th January 2026


Data Query Language (DQL) is a part of SQL used only to retrieve data from a database. It does not modify the data — it only queries (asks) the database.

  • DQL is mainly based on the SELECT command
  • It is used to:
    • fetch data
    • filter data
    • sort data
    • group data

Hinglish Tip 🗣: DQL ka kaam sirf data dekhna aur nikalna hota hai, data change karna nahi.


🧾 Core DQL Command

SELECT

SELECT * FROM students;
  • This query fetches all columns
  • From the students table

⚠️ SELECT is the only command in pure DQL.


🧩 Clauses Used with DQL

DQL becomes powerful when combined with SQL clauses.

ClausePurpose (High Level)
SELECTChoose columns
FROMChoose table
WHEREFilter rows
GROUP BYGroup rows
HAVINGFilter grouped data
ORDER BYSort result
LIMIT / OFFSETRestrict rows
JOINJoin multiple tables

Note: We Wil Cover Each Clause In Upcoming Tutorials


🔢 Clause Order Matters (Very Important)

SQL clauses must follow a fixed logical order. Changing the order can cause errors or wrong results.

OrderClause
1SELECT
2FROM
3JOIN
4WHERE
5GROUP BY
6HAVING
7ORDER BY
8LIMIT / OFFSET

Example Showing Clause Order

SELECT department, AVG(salary)
FROM employees
WHERE salary > 30000
GROUP BY department
HAVING AVG(salary) > 40000
ORDER BY AVG(salary) DESC
LIMIT 5;

👉 Focus here is order, not logic. Each clause appears in its correct position.