Ira SQL ProIra SQL Pro

SQL SELECT Statement

beginnerbasics
2 min read

What is the SELECT Statement?

The SELECT statement is the most fundamental SQL command. It retrieves data from one or more tables in a database. Every SQL query you write starts with SELECT.

When you run a SELECT statement, the database engine reads the specified columns from the target table and returns them as a result set. You can select all columns using * or pick specific ones by name.

Syntax

SELECT column1, column2, ...
FROM table_name;

To select every column:

SELECT * FROM table_name;

When to Use

Use SELECT whenever you need to read data from the database:

  • Viewing all records in a table
  • Retrieving specific columns for a report
  • Combining with WHERE to filter results
  • Using expressions to compute values on the fly

Key Points

  1. Column Order — You control the order of columns in the result by listing them in the desired sequence.
  2. Expressions — You can use arithmetic, string functions, and other expressions directly in SELECT.
  3. Star SelectorSELECT * returns all columns. In production, prefer naming columns explicitly for clarity and performance.
  4. Case Insensitivity — SQL keywords like SELECT and FROM are case-insensitive, but the convention is to write them in uppercase.
  5. No Side Effects — A SELECT statement never modifies data; it only reads.

Mastering SELECT is the first step to becoming proficient in SQL. Every filter, join, and aggregation builds on top of this command.

Guided Practice

Solve the challenge below. Use hints when stuck and check your answer for instant feedback.

Practice challengeGuided learning mode

SQL SELECT Statement Challenge

Write a query that retrieve every column and every row from the students table.

Expected result

All rows from the students table with columns: id, first_name, last_name, email, age, grade.

Hidden checks

  • Returned rows and values
  • Output columns and result shape
  • Final database state after the query runs

Lesson guidance

What is the SELECT Statement?

Initializing database...Each run starts from fresh sample data.

More Examples

Select specific columns

Retrieve only the name and email of each student.

Initializing database...Each run starts from fresh sample data.

Select with an expression

Calculate a value inline using an arithmetic expression.

Initializing database...Each run starts from fresh sample data.

Frequently Asked Questions

What does SELECT * mean in SQL?
SELECT * tells the database to return every column from the specified table. While convenient for exploration, it is best practice to list only the columns you need in production queries.
Can I use SELECT without a FROM clause?
Yes. In PostgreSQL you can write SELECT 1 + 1; or SELECT now(); to evaluate expressions without referencing a table.
Is SELECT case-sensitive in PostgreSQL?
SQL keywords like SELECT are case-insensitive. However, if you quote identifiers with double quotes, PostgreSQL treats them as case-sensitive.

Related Topics