Skip to content

SQL SELECT Statement

Syntax

The SELECT statement in SQL is used to retrieve specific columns or all columns from a table.

-- Retrieve a single column
SELECT column1
FROM table_name;
-- Retrieve multiple columns
SELECT column1, column2
FROM table_name;

Example

-- Retrieve a single column
SELECT name
FROM employees;
/* Output:
| name |
|------------|
| John Doe |
| Jane Smith |
| Alice Brown|
*/
-- Retrieve multiple columns
SELECT name, age
FROM employees;
/* Output:
| name | age |
|------------|-----|
| John Doe | 30 |
| Jane Smith | 25 |
| Alice Brown| 40 |
*/