Cheet Sheet – SQL πŸ›’οΈ

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. πŸ‘‹πŸΌ

CommandDescription
SELECTRetrieves data from a table.
FROMSpecifies the table to retrieve data from.
WHEREFilters records based on conditions.
INSERT INTOInserts new records into a table.
UPDATEUpdates existing records in a table.
DELETEDeletes records from a table.

CommandDescription
CREATE TABLE table_nameCreates a new table.
DROP TABLE table_nameDeletes an existing table.
ALTER TABLE table_nameModifies an existing table (e.g., add/drop columns).
TRUNCATE TABLE table_nameDeletes all rows from a table but keeps its structure.

CommandDescription
SELECT * FROM table_nameSelects all columns from a table.
SELECT column1, column2Selects specific columns from a table.
WHERE conditionFilters records based on conditions (e.g., age > 30).
ORDER BY column_nameSorts records by a specified column.
GROUP BY column_nameGroups records by a specified column.
HAVING conditionFilters grouped records.
DISTINCTReturns unique values in a column.

CommandDescription
INNER JOINReturns matching records from both tables.
LEFT JOINReturns all records from the left table and matching records from the right.
RIGHT JOINReturns all records from the right table and matching records from the left.
FULL OUTER JOINReturns all records from both tables, whether they match or not.

FunctionDescription
COUNT(column_name)Counts the number of rows.
SUM(column_name)Returns the sum of a numeric column.
AVG(column_name)Returns the average value of a numeric column.
MAX(column_name)Returns the maximum value in a column.
MIN(column_name)Returns the minimum value in a column.

CommandDescription
INSERT INTO table_nameAdds a new record.
VALUES (value1, value2)Specifies values for the new record.
UPDATE table_nameUpdates existing records in a table.
SET column_name = valueSpecifies the columns and values to update.
DELETE FROM table_nameDeletes records from a table.
WHERE conditionAdds a condition for the deletion.

OperatorDescription
=Equals
<> or !=Not equals
< or >Less than / Greater than
<= or >=Less than or equal / Greater than or equal
BETWEENSpecifies a range of values
LIKEMatches a pattern
INMatches any value in a list
IS NULLFinds NULL values
AND, OR, NOTCombines multiple conditions

…………

Thank you for your time; sharing is caring! 🌍

…………

Leave a Reply

Your email address will not be published. Required fields are marked *