As commitment to our database literacy campaign, we're offering our Certified Database Practitioner course—for FREE!
Some of the fundamental SQL commands used to interact with relational databases.
The cornerstone of data retrieval in SQL databases.
Basic Syntax Structure:
SELECT column1, column2 FROM table_name WHERE condition;
Column Selection Techniques:
SELECT *
)AS
keywordCOALESCE
and IFNULL
functionsData Filtering with WHERE Clause:
=
, <>
, <
, >
, <=
, >=
)AND
, OR
, NOT
)LIKE
and wildcards (%
, _
)BETWEEN
and IN
Result Organization:
ORDER BY
(ascending/descending)GROUP BY
and aggregate functions (COUNT
, SUM
, AVG
, MIN
, MAX
)HAVING
clauseLIMIT
/OFFSET
or TOP
/ROWNUM
Joining Tables:
Subqueries and Common Table Expressions (CTEs)
WITH
clause for more readable complex queriesAdding new records to database tables.
Single Row Insertion:
INSERT INTO table_name (column1, column2) VALUES (value1, value2);
Multiple Row Insertion:
INSERT INTO table_name (column1, column2)
VALUES (value1, value2), (value3, value4), (value5, value6);
Insertion with Subqueries:
INSERT INTO target_table (column1, column2)
SELECT column_a, column_b FROM source_table WHERE condition;
Default and Auto-generated Values:
Handling Constraint Violations:
Bulk Insert Operations:
Modifying existing records in database tables.
Basic Syntax:
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
Update Techniques:
SET salary = salary * 1.1
)Conditional Updates:
Mass Updates vs. Targeted Updates:
Updating with Joins:
UPDATE table1 t1
JOIN table2 t2 ON t1.id = t2.id
SET t1.column = t2.column
WHERE condition;
Safe Update Practices:
Removing records from database tables.
Basic Syntax:
DELETE FROM table_name WHERE condition;
Safe Deletion Practices:
Targeted vs. Mass Deletion:
Cascading Deletes:
Multi-table Deletes:
DELETE t1 FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id
WHERE condition;
Soft Deletes vs. Hard Deletes: