Catalog / SQL Cheatsheet
SQL Cheatsheet
A comprehensive guide to SQL syntax, commands, and best practices for data manipulation and database management.
Basic SQL Commands
SELECT Statement
The Syntax:
|
Example:
|
Select all columns using
|
INSERT Statement
The Syntax:
|
Example:
|
Insert into all columns (order matters!).
|
UPDATE Statement
The Syntax:
|
Example:
|
DELETE Statement
The Syntax:
|
Example:
|
Delete all records from a table (use with caution!).
|
CREATE TABLE Statement
The Syntax:
|
Example:
|
DROP TABLE Statement
The Syntax:
|
Example:
|
Filtering and Sorting
WHERE Clause
The Syntax:
|
Example:
|
Using
|
ORDER BY Clause
The Syntax:
|
Example:
|
Sorting by multiple columns.
|
LIKE Operator
The Syntax:
|
|
Example:
|
|
BETWEEN Operator
The Syntax:
|
Example:
|
IN Operator
The Syntax:
|
Example:
|
DISTINCT Keyword
The Syntax:
|
Example:
|
Joins and Unions
INNER JOIN
The Syntax:
|
Example:
|
LEFT JOIN
The Syntax:
|
Example:
|
RIGHT JOIN
The Syntax:
|
Example:
|
FULL OUTER JOIN
The Syntax:
|
Example:
|
UNION Operator
The Syntax:
|
Example:
|
UNION ALL Operator
The Syntax:
|
Example:
|
Aggregate Functions and Grouping
Aggregate Functions
Aggregate functions perform a calculation on a set of values and return a single value.
|
Example:
|
|
GROUP BY Clause
The Syntax:
|
Example:
|
HAVING Clause
The Syntax:
|
Example:
|
Subqueries
A subquery is a query nested inside another query. Syntax:
|
Example:
|
EXISTS Operator
The Syntax:
|
Example:
|