Skip to content
BENIBIX Learn

SELECT Statement

Development🗃️ DatabasesDatabase Basics

Also known as SELECT, SQL SELECT, SELECT Query, SELECT FROM

The SQL command that reads data out of a table.

Think of it like

It is like asking a shop helper for things off the shelf. You say what you want and they bring it.

Example

Emma wants the names of all her customers. She runs SELECT name FROM customers, and gets back one row per customer.

Why it matters

It is the command people run most in SQL. Every report, search and list in an app starts with a SELECT.

Definition

A SELECT statement is the SQL command that reads data from a database. You name the columns you want after SELECT, and the table after FROM. The database sends back the matching rows as a small table. You can add parts to it. WHERE picks rows, ORDER BY sorts them and LIMIT says how many to send.

Example code

sql
SELECT name, city
FROM customers
ORDER BY name
LIMIT 10;
Two columns from the customers table, sorted by name, first ten rows only.
A SELECT can filter, group and count before it sends rows back.

Common mistake

Using SELECT * in app code. It sends every column, even ones you never use, which is slower and breaks when columns change.

Key takeaways

  1. 1
    Columns, then table. SELECT what, FROM where.
  2. 2
    Add parts as needed. WHERE, ORDER BY, LIMIT.
  3. 3
    Reads, never changes. A SELECT leaves the data as it was.