SQL Quest
Sign in Français 0 XP Lvl 1
Beginner

SQL SELECT: read data from a table

4 min read · 3 runnable examples · updated October 9, 2026

SELECT is the first statement everyone learns in SQL, and the one you will write most often. It is used to read data: show the content of a table, pick a few columns, compute new values. It never changes the database, so you can try it without any risk.

In this lesson, you will see how to write a SELECT query, how to choose the columns to display, and why the famous SELECT * is handy… but not always a good idea.

Syntax

SELECT column1, column2, …
FROM table_name;

How it works

A SELECT query reads almost like a sentence: “select these columns from this table”.

  • SELECT lists the columns to display, separated by commas. They appear in the order you write them.
  • FROM names the table that holds these columns.
  • The star * means “all columns”. SELECT * FROM produits therefore shows the whole table.
  • The semicolon ; ends the query. It is required when you chain several queries.

SQL keywords are not case-sensitive: select and SELECT work the same way. The convention is to write keywords in upper case and table and column names in lower case, so the query is easy to read.

Why avoid SELECT * in an application?

SELECT * is perfect for exploring a table. In a real application, you usually list the columns you need: the query transfers less data, and it does not break if someone adds or reorders columns in the table.

Diagram

produits
idnomcategorieprix
1ClavierInformatique49
2PlaidMaison25
3GourdeSport12
result
nomprix
Clavier49
Plaid25
Gourde12
SELECT nom, prix FROM produits: every row is kept, but only the requested columns.

Simplified diagram to show the idea. The examples below use the real SQL Quest practice database (a fictional online shop: see the full schema).

Glossary: the sample database uses French names
clients
customers
commandes
orders
lignes_commande
order lines
produits
products
fournisseurs
suppliers
employes
employees
prenom / nom
first name / last name (or name)
ville
city
pays
country
prix
price
prix_unitaire
unit price
quantite
quantity
categorie
category
date_commande
order date
poste
job title
departement
department
salaire
salary
statut
status: livrée = delivered, expédiée = shipped, en cours = in progress, annulée = cancelled

Examples with their results

1. Show a whole table

The star shows every column of the fournisseurs (suppliers) table.

SELECT * FROM fournisseurs;
Try it in the sandbox
Result
idnompays
1TechNovaFrance
2ElectroPlusAllemagne
3MaisonDecoFrance
4SportZoneEspagne
5BookWorldBelgique
6GreenFoodItalie
7AsiaPartsChine

7 rows in total

2. Choose your columns

Only the name and price of each product, in that order.

SELECT nom, prix FROM produits;
Try it in the sandbox
Result
nomprix
Clavier mécanique15
Souris sans fil103
Écran 27"342
Webcam HD101
SSD 1To317
Casque gaming98
Hub USB-C49
Lampe LED51.74
Coussin10.86
Plaid29.23

29 rows in total · 10 shown

3. Change the column order

The column order in the result follows the order written after SELECT, not the order of the table.

SELECT ville, nom, prenom FROM clients;
Try it in the sandbox
Result
villenomprenom
LilleDuboisSamir
LilleMartinSamir
ParisLaurentZoé
ToulouseLefebvreRayan
MarseilleLaurentLéa
BordeauxMichelLouis
CasablancaDuboisAdam
MontréalLambertOmar
BordeauxFaureZoé
LyonFaureAlice

120 rows in total · 10 shown

Common mistakes

Forgetting the comma between two columns

Without a comma, SQL reads the second word as an alias (a new name) for the first column. The query does not fail: it returns a single column, which is even more misleading.

Avoid
SELECT prenom nom FROM clients;
Correct
SELECT prenom, nom FROM clients;

Leaving a comma before FROM

A comma after the last column causes a syntax error.

Avoid
SELECT prenom, nom, FROM clients;
Correct
SELECT prenom, nom FROM clients;

Misspelling the table name

Names must be exact. In our database, tables are plural: clients, produits, commandes…

Avoid
SELECT * FROM client;
Correct
SELECT * FROM clients;

Exercises

Try writing the query yourself before opening the solution.

Challenge 1. Show the email address and the city of every customer.

Show a solution
SELECT email, ville FROM clients;
emailville
samir.dubois1@mail.comLille
samir.martin2@mail.comLille
zoe.laurent3@mail.comParis
rayan.lefebvre4@mail.comToulouse
lea.laurent5@mail.comMarseille
louis.michel6@mail.comBordeaux
adam.dubois7@mail.comCasablanca
omar.lambert8@mail.comMontréal

120 rows in total · 8 shown

Try it in the sandbox

Challenge 2. Show the last name, job title and salary of every employee.

Show a solution
SELECT nom, poste, salaire FROM employes;
nompostesalaire
DuboisPDG9,500
LefebvreDirecteur commercial6,200
RouxDirectrice technique6,800
SimonResponsable RH4,800
SimonCommercial4,800
MartinCommercial3,400
MoreauCommercial4,600
LambertCommercial4,200

25 rows in total · 8 shown

Try it in the sandbox
Want more practice?

The interactive exercises are checked automatically, with a tutor who explains your mistakes. A short lesson stays next to the editor.

Do the interactive exercises

Frequently asked questions

Does SELECT change the database?

No. SELECT only reads data. To change a table, you use INSERT, UPDATE or DELETE.

Do I have to write SELECT in upper case?

No, SQL keywords are not case-sensitive. Upper case is a convention that makes queries easier to read.

Is the semicolon required?

For a single query, most tools accept it without one. It becomes required as soon as you chain several queries, so get into the habit of always adding it.

In what order are the rows returned?

Without ORDER BY, the row order is not guaranteed. If the order matters, add an ORDER BY clause (see the dedicated lesson).

Read next