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
SELECT column1, column2, ... FROM table_name WHERE condition ORDER BY column1 ASC|DESC LIMIT n;
Examples
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 PlaygroundSelect 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 PlaygroundSelect 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 PlaygroundCommon 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?
Can you SELECT from multiple tables?
What is the difference between SELECT and SELECT DISTINCT?
How do you alias a column in SQL SELECT?
Related SQL Topics
Practice This in the SQL Playground
Write real queries, see live results, and master SQL SELECT Statement hands-on. 100% free.