Skip to content

SQL Select

SELECT reads data out of a table. You name the columns you want and the table they live in, and the database hands back a result set: a temporary table holding just those columns, one row for every row in the source.

The examples use the Productions table from the example database, an invented list of film and TV productions:

ProductionID Title Format Country Budget
1 The Lantern Keepers Drama series UK 18,500,000
2 Quarry Lane Feature film UK 7,200,000
3 Saltmarsh Feature film Ireland 3,900,000
4 Six Bells Drama series UK 11,000,000
5 Fennick’s Return Documentary Canada 850,000

List the columns after SELECT, separated by commas, and the table after FROM:

SELECT column1, column2
FROM table_name;

To see each production’s title and where it is made:

SELECT Title, Country
FROM Productions;
Title Country
The Lantern Keepers UK
Quarry Lane UK
Saltmarsh Ireland
Six Bells UK
Fennick’s Return Canada

The columns come back in the order you list them, whatever their order in the table.

An asterisk stands for every column in the table:

SELECT * FROM Productions;

This returns the whole table above.