sqlcmd.net validated sql reference

Beginner commands

Guides grouped by the expected difficulty and amount of SQL context they assume.

36 commands in this rank Step through by experience level
beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Add A Column To An Existing Table

Extend a table's structure by adding a new column with `ALTER TABLE`.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Calculate Averages With AVG

Compute the arithmetic mean of numeric values across matching rows.

beginner string-processing MySQL MariaDB SQL Server PostgreSQL SQLite

Change Text Case With UPPER And LOWER

Convert string values to all uppercase or all lowercase using `UPPER` and `LOWER`.

beginner null-handling MySQL MariaDB SQL Server PostgreSQL SQLite

Check For NULL Values With IS NULL

Use `IS NULL` and `IS NOT NULL` to filter rows based on whether a column has a value.

beginner date-time MySQL MariaDB SQL Server PostgreSQL SQLite

Convert Timestamps To Dates

Strip the time portion from a timestamp so only the calendar date remains.

beginner conversion MySQL MariaDB SQL Server PostgreSQL SQLite

Convert Values With CAST

Change a value from one SQL type to another using an explicit cast.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Count Rows With COUNT(*)

Aggregate a result set into a single row that reports how many rows matched.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Count Unique Values With COUNT DISTINCT

Count only the distinct values in a column, ignoring duplicates.

beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Create A Table

Define a new table with column names and data types using `CREATE TABLE`.

beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Delete A Table

Permanently remove a table and all its data with `DROP TABLE`.

beginner deleting MySQL MariaDB SQL Server PostgreSQL SQLite

Delete Rows

Remove matching rows with `DELETE`, then query the remaining table contents.

beginner filtering MySQL MariaDB SQL Server PostgreSQL SQLite

Filter Rows By Pattern With LIKE

Match string columns against a wildcard pattern using `LIKE`.

beginner filtering MySQL MariaDB SQL Server PostgreSQL SQLite

Filter Rows Matching A List With IN

Use `IN` to match a column against a list of values in a single `WHERE` clause.

beginner filtering MySQL MariaDB SQL Server PostgreSQL SQLite

Filter Rows With WHERE

Return only rows that match a condition, with explicit ordering for stable output.

beginner filtering MySQL MariaDB SQL Server PostgreSQL SQLite

Filter Rows Within A Range With BETWEEN

Use `BETWEEN` to match rows where a column falls within an inclusive lower and upper bound.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Find The Smallest And Largest Values With MIN And MAX

Use `MIN` and `MAX` to find the lowest and highest values in a column.

beginner date-time MySQL MariaDB SQL Server PostgreSQL SQLite

Get The Current Date And Time

Return the current date and time using `CURRENT_TIMESTAMP` or engine-specific functions.

beginner string-processing MySQL MariaDB SQL Server PostgreSQL SQLite

Get The Length Of A String

Return the number of characters in a string using `LENGTH` or `LEN`.

beginner inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert a Row

Add new data to a table, then verify the inserted row with a deterministic query.

beginner inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert Multiple Rows

Add several rows in one statement using a multi-value `INSERT`.

beginner string-processing MySQL MariaDB SQL Server PostgreSQL SQLite

Join Strings With CONCAT

Combine multiple text values into one string in the query result.

beginner pagination MySQL MariaDB SQL Server PostgreSQL SQLite

Limit Returned Rows

Return only part of a result set using the row-limiting syntax each engine supports.

beginner metadata MySQL MariaDB SQL Server PostgreSQL SQLite

List Columns In A Table

Inspect a table definition to see its column names and data types.

beginner metadata MySQL MariaDB SQL Server PostgreSQL SQLite

List Tables

Inspect the current database or schema to see which tables exist.

beginner selecting MySQL MariaDB SQL Server PostgreSQL

Rename Output Columns With AS

Use `AS` to give result columns clearer labels without changing the underlying table schema.

beginner conditional-logic MySQL MariaDB SQL Server PostgreSQL SQLite

Replace NULL Values With COALESCE

Return the first non-null value from a list of expressions.

beginner string-processing MySQL MariaDB SQL Server PostgreSQL SQLite

Replace Text Within A String With REPLACE

Substitute all occurrences of a substring with a new value using `REPLACE`.

beginner deduplication MySQL MariaDB SQL Server PostgreSQL SQLite

Return Distinct Values

Use `DISTINCT` to remove duplicate rows from a result set.

beginner retrieval MySQL MariaDB SQL Server PostgreSQL SQLite

Select All Rows

Return every row from a table with an explicit sort order for deterministic output.

beginner ordering MySQL MariaDB SQL Server PostgreSQL SQLite

Sort By Multiple Columns

Use more than one sort key so ties are broken deterministically.

beginner ordering MySQL MariaDB SQL Server PostgreSQL SQLite

Sort Rows With ORDER BY

Control the order of result rows explicitly instead of relying on storage order.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Total Values With SUM

Add numeric values across matching rows and return one aggregate total.

beginner string-processing MySQL MariaDB SQL Server PostgreSQL SQLite

Trim Whitespace From Text

Remove leading and trailing whitespace from string values with `TRIM`.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Understand COUNT(column) Versus COUNT(*)

`COUNT(column)` skips `NULL` values, while `COUNT(*)` counts every row that made it into the result set.

beginner updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update Rows

Modify existing rows with `UPDATE`, then verify the changed data with a stable query.

beginner pagination MySQL MariaDB SQL Server PostgreSQL SQLite

Use LIMIT Or TOP With ORDER BY For Stable Results

A row limit without an explicit sort can return different rows over time or across engines.