beginnerCore SQL100% Free

SQL SELECT Statement

Definition

The SQL SELECT statement retrieves rows and columns from one or more database tables, optionally filtered, sorted, and limited.

Introduction to SQL SELECT Statement

The SELECT statement is the foundation of SQL. Every database query that retrieves data starts with SELECT. It tells the database engine which columns to return from which tables, and can be combined with WHERE, ORDER BY, GROUP BY, and LIMIT to precisely control the output.

Syntax

SQL
SELECT column1, column2, ...
FROM table_name
WHERE condition
ORDER BY column1 ASC|DESC
LIMIT n;

Examples

1

Select All Columns

SELECT * FROM employees;

The asterisk (*) wildcard selects every column from the employees table. Avoid in production — always name specific columns for performance.

Try in Playground
2

Select Specific Columns

SELECT name, salary, department
FROM employees
ORDER BY salary DESC;

Returns only the three specified columns, sorted by salary from highest to lowest.

Try in Playground
3

Select with Filter and Limit

SELECT name, salary
FROM employees
WHERE department = 'Engineering'
ORDER BY salary DESC
LIMIT 5;

Retrieves the top 5 highest-paid engineers by combining WHERE, ORDER BY, and LIMIT.

Try in Playground

Common Mistakes

Using SELECT * in production — always specify columns for clarity and performance

Forgetting the FROM clause — SELECT needs to know which table to query

Mixing column aliases incorrectly with WHERE (use HAVING or wrap in subquery instead)

Not using ORDER BY when expecting consistent result ordering

Frequently Asked Questions

What does SELECT * mean in SQL?
SELECT * retrieves all columns from a table. While convenient for exploration, it is inefficient in production because it transfers unnecessary data over the network and hides which columns are actually needed.
Can you SELECT from multiple tables?
Yes, using JOINs or subqueries. For example: SELECT e.name, d.name FROM employees e JOIN departments d ON e.dept_id = d.id;
What is the difference between SELECT and SELECT DISTINCT?
SELECT returns all rows including duplicates. SELECT DISTINCT removes duplicate rows from the result set, returning only unique combinations of the selected columns.
How do you alias a column in SQL SELECT?
Use the AS keyword: SELECT salary * 12 AS annual_salary FROM employees; The alias 'annual_salary' is shown as the column header in results.

Related SQL Topics

Practice This in the SQL Playground

Write real queries, see live results, and master SQL SELECT Statement hands-on. 100% free.