OVERVIEW   1 FROM   2 SELECT   3 WHERE   4 GO BACK   ←

SQL: SELECT

The SELECT keyword determines which fields an SQL statement will involve. They are taken from the table(s) listed after the FROM keyword.

In the example below, the name and grade fields are being displayed. Note the comma. One is required for each field listed past the first.

SELECT first_name, grade

FROM students;

first_name grade
Guy 88
James 73
Alice 96
Holly 83

To get every field without having to explicitly list it out, use an asterisk (*) instead.

SELECT *

FROM students;

id last_name first_name grade
001 Holmes Guy 88
002 Atwell James 73
003 O'Hara Alice 96
004 Peterson Holly 83

Following is an interactive SQL query. Click on the second through fourth fields to add or remove them from the query.

SELECT name, capital, language, population

FROM countries;

name capital language population
Spain Madrid Spanish 47350000
Iceland Reykjavík Icelandic 366425
Peru Lima Spanish 32000000
Vietnam Hanoi Vietnamese 97340000
BACK