SQL चीटशीट
SQL सिंटैक्स, joins, फ़ंक्शन और डेटा टाइप की त्वरित संदर्भ गाइड।
यह कैसे काम करता है
SQL evaluates logically as FROM/JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT/WINDOW -> DISTINCT -> ORDER BY -> LIMIT, even though `SELECT` is written first.
सर्वाइवल किट
वे कुछ कमांड जिन्हें सबसे पहले सीखना चाहिए।
42 कमांड
Select, Filter & Pagination
Filter predicates safely, avoid NULL traps, sort, and paginate efficiently.
- आवश्यक
Filter rows, sort deterministically, and cap returned rows
SELECT <cols> FROM <table> WHERE <cond> ORDER BY <col> DESC LIMIT <n>;कमांड बनाएँ
SELECT <cols> FROM <table> WHERE <cond> ORDER BY <col> DESC LIMIT <n>;मान ठीक वैसे ही डाले जाते हैं जैसे टाइप किए गए हैं। यदि उनमें स्पेस या विशेष वर्ण हों तो स्वयं उद्धरण चिह्न लगाएँ।
इसका उपयोग कब करें
Adding a tie-breaker column to `ORDER BY` guarantees repeatable pagination order.
उदाहरण
SELECT id, email, created_at FROM users WHERE status = 'active' ORDER BY created_at DESC, id DESC LIMIT 25;
Joins & Set Operations
Combine related tables cleanly and find orphan or unmatched rows.
Aggregation, CTEs & Window Functions
Group metrics, stage readable queries with CTEs, and rank without collapsing rows.
Insert, Upsert, Update & Delete
Write idempotent mutations safely inside transactions without locking accidents.
Schema, Constraints, JSON & Performance
Design tables, composite indexes, JSON queries, and inspect EXPLAIN plans.