SQL Reference
SQL statements, clauses, operators and functions. Examples run on the practice shop database.
49 of 49
| Keyword | Type | Description |
|---|---|---|
| SELECT | Statement | Chooses columns to return. |
| SELECT DISTINCT | Statement | Returns only different values. |
| FROM | Clause | Names the table to read. |
| WHERE | Clause | Filters rows. |
| ORDER BY | Clause | Sorts the result. |
| LIMIT | Clause | Limits the number of rows. |
| OFFSET | Clause | Skips rows before returning. |
| GROUP BY | Clause | Groups rows for aggregates. |
| HAVING | Clause | Filters groups. |
| AS | Clause | Gives a column or table an alias. |
| AND | Operator | Both conditions must be true. |
| OR | Operator | Either condition may be true. |
| NOT | Operator | Reverses a condition. |
| IN | Operator | Matches any value in a list. |
| BETWEEN | Operator | Matches a range, inclusive. |
| LIKE | Operator | Matches a text pattern. |
| IS NULL | Operator | Tests for no value. |
| COUNT() | Function | Counts rows. |
| SUM() | Function | Adds up numbers. |
| AVG() | Function | The average. |
| MIN() | Function | The smallest value. |
| MAX() | Function | The largest value. |
| ROUND() | Function | Rounds a number. |
| UPPER() | Function | Upper-case text. |
| LOWER() | Function | Lower-case text. |
| LENGTH() | Function | The number of characters. |
| SUBSTR() | Function | Part of a string. |
| REPLACE() | Function | Replaces text. |
| COALESCE() | Function | The first value that is not NULL. |
| CASE | Function | If-then logic inside a query. |
| CAST() | Function | Converts a value to another type. |
| INNER JOIN | Join | Rows with a match in both tables. |
| LEFT JOIN | Join | All rows from the left table, matched where possible. |
| CROSS JOIN | Join | Every combination of rows. |
| UNION | Set | Combines results, removing duplicates. |
| UNION ALL | Set | Combines results, keeping duplicates. |
| EXISTS | Subquery | True if a subquery returns rows. |
| Subquery | Subquery | A query inside another query. |
| INSERT INTO | Statement | Adds rows. |
| UPDATE | Statement | Changes rows. |
| DELETE | Statement | Removes rows. |
| CREATE TABLE | Statement | Creates a table. |
| ALTER TABLE | Statement | Changes a table. |
| DROP TABLE | Statement | Deletes a table. |
| CREATE INDEX | Statement | Speeds up lookups on a column. |
| PRIMARY KEY | Constraint | Uniquely identifies each row. |
| NOT NULL | Constraint | The column must have a value. |
| DEFAULT | Constraint | A value used when none is given. |
| UNIQUE | Constraint | No two rows may share the value. |