SELECT Statements in SQL
From the SQL cheat sheet ยท SELECT & Filtering ยท verified Jul 2026
SELECT Statements
Retrieve data with filtering, sorting, and limiting.
sql
-- Select all columns
SELECT * FROM users;
-- Select specific columns
SELECT name, email FROM users;
-- WHERE filtering
SELECT * FROM users WHERE age > 18;
SELECT * FROM users WHERE city IN ('NYC', 'LA');
SELECT * FROM users WHERE age BETWEEN 25 AND 35;
-- Sorting
SELECT * FROM users ORDER BY name ASC;
SELECT * FROM users ORDER BY age DESC, name ASC;๐ก Use column aliases (AS) to rename output columns โ makes results more readable
โก LIMIT syntax varies: MySQL/PostgreSQL use LIMIT, SQL Server uses TOP, ANSI uses FETCH
๐ IS NULL is the only way to check for NULL โ "= NULL" does not work
๐ข ORDER BY defaults to ASC โ only add DESC when you need descending order
selectwhereorder-bylimit