SQL SELECT Statement

The SQL SELECT statement is used to select data from SQL database.
It returns a result-set which stores the result as a table.

SQL SELECT basic syntax:

SELECT column1, column2, column3
FROM table_name

If you want to select all columns from a database table, you can use the following statement:

SELECT *
FROM table_name

note 1: SQL statement is not case sensitive, SELECT is same with select.

note 2: Explicitly specifying the columns in the SELECT list has better query performance.
Example of SQL SELECT

Scenario: A travel agency wants to list cities information.
Table: Cities

CityId City State_Province Country
1 New York New York USA
2 Miami Florida USA
3 Washington D.C. USA
4 Toronto Ontario Canada
5 Calgary Alberta Canada

If we use the following SQL SELECT statement:

SELECT City, Country
FROM cities

The result set will look like:

City Country
New York USA
Miami USA
Washington D.C. USA
Toronto Canada
Calgary Canada

If we use the following SQL SELECT statement:

SELECT *
FROM cities

The result set will look like:

CityId City State_Province Country
1 New York New York USA
2 Miami Florida USA
3 Washington D.C. USA
4 Toronto Ontario Canada
5 Calgary Alberta Canada

Leave a Comment