Easy Tutorial
❮ Func Now Sql Insert ❯

SQL SELECT Statement


The SELECT statement is used to select data from a database.


SQL SELECT Statement

The SELECT statement is used to select data from a database.

The result is stored in a result table, called the result set.

SQL SELECT Syntax

SELECT column1, column2, ...
FROM table_name;

and

SELECT * FROM table_name;

Parameter Description:


Demonstration Database

In this tutorial, we will use the tutorialpro sample database.

Below is data selected from the "Websites" table:

+----+--------------+---------------------------+-------+---------+
| id | name         | url                       | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1  | Google       | https://www.google.cm/    | 1     | USA     |
| 2  | Taobao       | https://www.taobao.com/   | 13    | CN      |
| 3  | tutorialpro.org      | http://www.tutorialpro.org/    | 4689  | CN      |
| 4  | Weibo        | http://weibo.com/         | 20    | CN      |
| 5  | Facebook     | https://www.facebook.com/ | 3     | USA     |
+----+--------------+---------------------------+-------+---------+

SELECT Column Example

The following SQL statement selects the "name" and "country" columns from the "Websites" table:

Example

SELECT name,country FROM Websites;

Output result:


SELECT * Example

The following SQL statement selects all columns from the "Websites" table:

Example

SELECT * FROM Websites;

Output result:


Navigation in the Result Set

Most database software systems allow the use of programming functions to navigate within the result set, such as: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc.

These programming functions are not covered in this tutorial. To learn about accessing data through function calls, please visit our ADO Tutorial or PHP Tutorial.

❮ Func Now Sql Insert ❯