I am sure you can find cheet sheets about sql from many sources but I hope that having all the examples and exercises in one place will be useful for you. π
Your feedback is very valuable to me, I am looking forward to hearing it. ππΌ
Basic SQL Commands
Command
Description
SELECT
Retrieves data from a table.
FROM
Specifies the table to retrieve data from.
WHERE
Filters records based on conditions.
INSERT INTO
Inserts new records into a table.
UPDATE
Updates existing records in a table.
DELETE
Deletes records from a table.
Table Operations
Command
Description
CREATE TABLE table_name
Creates a new table.
DROP TABLE table_name
Deletes an existing table.
ALTER TABLE table_name
Modifies an existing table (e.g., add/drop columns).
TRUNCATE TABLE table_name
Deletes all rows from a table but keeps its structure.
Data Selection and Filtering
Command
Description
SELECT * FROM table_name
Selects all columns from a table.
SELECT column1, column2
Selects specific columns from a table.
WHERE condition
Filters records based on conditions (e.g., age > 30).
ORDER BY column_name
Sorts records by a specified column.
GROUP BY column_name
Groups records by a specified column.
HAVING condition
Filters grouped records.
DISTINCT
Returns unique values in a column.
Join Operations
Command
Description
INNER JOIN
Returns matching records from both tables.
LEFT JOIN
Returns all records from the left table and matching records from the right.
RIGHT JOIN
Returns all records from the right table and matching records from the left.
FULL OUTER JOIN
Returns all records from both tables, whether they match or not.