DML Statements
| Name |
Syntax |
Description |
|
|
SELECT
|
SELECT column1, column2 FROM table WHERE condition...
|
Retrieves rows from one or more tables. The most frequently used SQL statement.
|
Details →
|
|
INSERT
|
INSERT INTO table (col1, col2) VALUES (val1, val2)...
|
Inserts new rows into a table. Can insert single or multiple rows in one statement.
|
Details →
|
|
UPDATE
|
UPDATE table SET col1 = val1 WHERE condition;
|
Modifies existing rows in a table. Always use WHERE to avoid updating all rows.
|
Details →
|
|
DELETE
|
DELETE FROM table WHERE condition;
|
Removes rows from a table. Always include WHERE unless you intend to delete all rows.
|
Details →
|
|
JOIN
|
SELECT ... FROM t1 INNER JOIN t2 ON t1.id = t2.t1_...
|
Combines rows from two or more tables. INNER returns matching rows; LEFT returns all left rows.
|
Details →
|
DDL Statements
| Name |
Syntax |
Description |
|
|
CREATE TABLE
|
CREATE TABLE table_name (column_definitions, const...
|
Creates a new table in the database with defined columns, data types, and constraints.
|
Details →
|
|
ALTER TABLE
|
ALTER TABLE table ADD | DROP | MODIFY | RENAME ......
|
Modifies an existing table structure: add/drop columns, change data types, add indexes.
|
Details →
|
|
CREATE INDEX
|
CREATE INDEX index_name ON table (column);
|
Creates an index on a table column to speed up query performance.
|
Details →
|
Clauses & Keywords
| Name |
Syntax |
Description |
|
|
WHERE
|
WHERE condition1 AND|OR condition2
|
Filters rows based on one or more conditions. Supports comparison, logical, LIKE, IN, BETWEEN, IS NULL.
|
Details →
|
|
GROUP BY / HAVING
|
GROUP BY column HAVING aggregate_condition
|
GROUP BY groups rows by column values; HAVING filters the grouped results (like WHERE for aggregates).
|
Details →
|
|
ORDER BY / LIMIT / OFFSET
|
ORDER BY col ASC|DESC LIMIT n OFFSET m
|
ORDER BY sorts results; LIMIT restricts the number of rows; OFFSET skips rows for pagination.
|
Details →
|
|
Subqueries
|
SELECT ... WHERE col IN (SELECT col FROM ...);
|
A query nested inside another query. Can be used in SELECT, FROM, WHERE, and HAVING clauses.
|
Details →
|
|
UNION / UNION ALL
|
SELECT ... UNION [ALL] SELECT ...
|
Combines result sets of two or more SELECT statements. UNION removes duplicates; UNION ALL keeps them.
|
Details →
|
Functions
| Name |
Syntax |
Description |
|
|
Aggregate Functions
|
COUNT() SUM() AVG() MIN() MAX()
|
Aggregate functions compute a single result from multiple rows. Used with GROUP BY for grouped summaries.
|
Details →
|
|
String Functions
|
CONCAT() SUBSTRING() UPPER() LOWER() TRIM() L...
|
Built-in MySQL string manipulation functions for transforming and extracting string data.
|
Details →
|
|
Date Functions
|
NOW() CURDATE() DATE_FORMAT() DATEDIFF() DATE_...
|
Built-in functions for working with date and time values in MySQL.
|
Details →
|
|
CASE WHEN
|
CASE WHEN condition THEN result ELSE default END
|
Conditional expression similar to if-else. Can be used in SELECT, WHERE, ORDER BY, and UPDATE.
|
Details →
|
|
COALESCE() / IFNULL()
|
COALESCE(val1, val2, ...) IFNULL(expr, alt)
|
COALESCE returns the first non-NULL value; IFNULL returns alt if expr is NULL.
|
Details →
|
No results found. Try a different search term.