SELECT Statement

SELECT is the SQL command for reading data from a database. You list the columns you want and the table to read them from, and the database returns the matching rows.

SQL

SELECT is the most-used command in SQL. Use SELECT * to grab every column, or name specific columns to return only what you need.

You refine a SELECT with extra clauses: WHERE filters rows, ORDER BY sorts them, and LIMIT caps how many come back.

Syntax

SELECT column1, column2 FROM table_name WHERE condition;

Examples

SQL

SELECT name, age FROM users WHERE age > 25;

Output:

name   age
-----  ---
Alice  30

Learn it in a lesson

See also

Back to the Dictionary