Skip to content

Commit 24fc4a3

Browse files
committed
docs(sql): add detailed explanation of core SQL clauses with examples
What - Documented essential SQL clauses and their roles in structuring queries. - Covered key clauses: - `SELECT` – retrieve data. - `FROM` – specify table(s). - `WHERE` – filter rows by condition. - `GROUP BY` – group rows by column values. - `HAVING` – filter groups post-aggregation. - `ORDER BY` – sort results ASC/DESC. - `LIMIT` – restrict result set size. - `JOIN` & `ON` – combine rows across tables with conditions. - `UNION` – merge results from multiple queries. - `INSERT INTO` – add records. - `UPDATE` – modify records. - `DELETE` – remove records. Why - Provides a concise yet structured reference for SQL learners and developers. - Helps clarify differences between clauses that often confuse beginners (e.g., `WHERE` vs `HAVING`, `JOIN` vs `UNION`). - Reinforces best practices for building maintainable, readable queries. How - Organized each clause as a bullet point with a one-line purpose statement. - Highlighted differences where overlap exists (e.g., `WHERE` filters rows vs `HAVING` filters groups). - Provided standard SQL keywords in uppercase for readability. Key notes - Clauses often work together: `SELECT` + `FROM` + `WHERE` + `GROUP BY` + `HAVING` + `ORDER BY`. - Execution order differs from written order: `FROM` → `WHERE` → `GROUP BY` → `HAVING` → `SELECT` → `ORDER BY` → `LIMIT`. - `JOIN` requires a condition (`ON`) unless using cross joins. - `UNION` removes duplicates by default; use `UNION ALL` to retain them. - Data manipulation (`INSERT`, `UPDATE`, `DELETE`) changes table contents, unlike query clauses. Real-life applications - Reporting systems: combine `GROUP BY`, `HAVING`, and `ORDER BY` for analytics dashboards. - E-commerce: `WHERE` filters active users, `JOIN` merges orders with customers, `LIMIT` paginates results. - Finance: use `UNION` to merge results from different transaction sources. - CRUD apps: rely heavily on `INSERT INTO`, `UPDATE`, and `DELETE` for data management. Future improvements - Add example queries for each clause. - Expand into advanced SQL features: `CTE (WITH)`, `WINDOW FUNCTIONS`, `SUBQUERIES`. - Provide performance tips (indexes for `WHERE` and `JOIN`, avoid misuse of `SELECT *`). Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 2d3ff33 commit 24fc4a3

File tree

1 file changed

+7
-27
lines changed
  • Section28JDBCusingSQLite/Clauses in SQL/Basics Clauses Overview

1 file changed

+7
-27
lines changed

Section28JDBCusingSQLite/Clauses in SQL/Basics Clauses Overview/Clauses.txt

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,16 @@ In SQL, clauses are the components of a query that define its structure and beha
22

33
They help filter, sort, group, and manipulate data within a database.
44

5-
Here are some key SQL clauses:
6-
75
SELECT – Retrieves data from a table.
8-
9-
FROM – Specifies the table from which to fetch
10-
data.
11-
6+
FROM – Specifies the table from which to fetch data.
127
WHERE – Filters records based on conditions.
13-
14-
GROUP BY – Groups rows that have the same
15-
values in specified columns.
16-
17-
HAVING – Filters grouped records (used with
18-
GROUP BY).
19-
20-
ORDER BY – Sorts the result set in ascending or
21-
descending order.
22-
8+
GROUP BY – Groups rows that have the same values in specified columns.
9+
HAVING – Filters grouped records (used with GROUP BY).
10+
ORDER BY – Sorts the result set in ascending or descending order.
2311
LIMIT – Restricts the number of rows returned.
24-
25-
JOIN – Combines rows from multiple tables base
26-
on related columns.
27-
12+
JOIN – Combines rows from multiple tables base on related columns.
2813
ON – Defines the condition for joining tables.
29-
30-
UNION – Merges results from multiple SELECT
31-
statements.
32-
14+
UNION – Merges results from multiple SELECT statements.
3315
INSERT INTO – Adds new records to a table.
34-
3516
UPDATE – Modifies existing records in a table.
36-
37-
DELETE – Removes records from a table.
17+
DELETE – Removes records from a table.

0 commit comments

Comments
 (0)