Commit 24fc4a3
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 changedLines changed: 7 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 6 | + | |
12 | 7 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
23 | 11 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 12 | + | |
28 | 13 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 14 | + | |
33 | 15 | | |
34 | | - | |
35 | 16 | | |
36 | | - | |
37 | | - | |
| 17 | + | |
0 commit comments