Code has been added to clipboard!

SQL SELECT and SELECT ALL Statements

Reading time 1 min
Published Jan 4, 2016
Updated Oct 9, 2019

TL;DR – The SQL SELECT command is commonly used for search queries. Using it, you can select specific data from your SQL databases. The data you select is stored in a table called a result-set.

Syntax of SQL SELECT

Selecting specific columns

Example
SELECT column1, column2, ...
FROM table_name;

Selecting all columns

Example
SELECT * FROM table_name;

Examples using a demo database

The Users table

ID Username Email Password
1 alfredfutter alfredfutter@gmail.com secret1
2 atrujillo atrujillo@gmail.com secret2
3 moreno.antonio moreno.antonio@yahoo.com secret3
4 hardythomas thomas.hardy@gmail.com secret4
5 bergluns bergluns@gmail.com secret5

Using SELECT to retrieve data of specific columns

Example
SELECT username,email 
FROM users;

Using SELECT to retrieve data of all columns

Example
SELECT * FROM users;

Note: SELECT * selects all columns, SELECT ALL selects all rows.

Learn SQL
Introduction
Syntax
Data Types
Server Data Types
Commands
Commands List
Wildcards
Constraints
Aggregate Functions
Date Functions
Date Format
Injection
SQL Server Hosting
Views
Auto-incrementation
SQL Operators
AS
AND & OR
IN
BETWEEN
WHERE
GROUP BY
HAVING
ORDER BY
LIKE
NOT
NOT EQUAL
UNION
NULL
NOT NULL
DEFAULT
UNIQUE
FOREIGN KEY
PRIMARY KEY
CHECK
Indexes
ALTER TABLE
CREATE DATABASE
CREATE TABLE
DELETE
DROP
INSERT INTO SELECT
INSERT INTO
SELECT
SELECT DISTINCT
SELECT INTO
SELECT TOP
UPDATE
FULL OUTER JOIN
INNER JOIN
JOIN
LEFT JOIN
RIGHT JOIN
AVG()
COUNT
FIRST
LAST
MAX
MIN()
SUM()
LEN
UCASE
MID
NOW
ROUND
FORMAT
LOWER
CONVERT
ISNULL