SQL

Statement Description Example
WHERE Filters rows based on a specified condition.
SELECT * FROM table_name WHERE condition_1;
AND Combines multiple conditions in a WHERE clause, requiring all to be true.
SELECT * FROM table_name WHERE condition_1 AND condition_2;
OR Combines multiple conditions in a WHERE clause, requiring at least one to be true.
SELECT * FROM table_name WHERE condition_1 OR condition_2;
LIMIT Limits the number of rows returned by a query.
SELECT * FROM table_name LIMIT 10;
GROUP BY Groups rows that have the same values into summary rows.
SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name;
ORDER BY Sorts the result set by specified columns (ASC or DESC).
SELECT * FROM table_name ORDER BY column_name ASC|DESC;
COUNT Counts the number of rows in a specified column or all rows.
SELECT COUNT(*) FROM table_name;
AS Aliases are used to rename a table or column in a SQL query result.
SELECT column_name AS alias_name FROM table_name;
INNER JOIN Returns records that have matching values in both tables.
SELECT * FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name;
LEFT JOIN Returns all records from the left table and the matched records from the right table.
SELECT * FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;
RIGHT JOIN Returns all records from the right table and the matched records from the left table.
SELECT * FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;
FULL JOIN Returns all records when there is a match in either left or right table.
SELECT * FROM table1 FULL JOIN table2 ON table1.column_name = table2.column_name;