SQL SELECT statement
SELECT statement is used to select data from the database.
SQL SELECT statement
SELECT statement is used to select data from the database.
The results are stored in a result table, called the result set.
SQL SELECT syntax
FROM table_name ;
versus
The demo database
In this tutorial, we will use w3big sample database.
The following is a selected "Websites" table data:
+----+--------------+---------------------------+-------+---------+ | id | name | url | alexa | country | +----+--------------+---------------------------+-------+---------+ | 1 | Google | https://www.google.cm/ | 1 | USA | | 2 | 淘宝 | https://www.taobao.com/ | 13 | CN | | 3 | 本教程 | http://www.w3write.com/ | 4689 | CN | | 4 | 微博 | http://weibo.com/ | 20 | CN | | 5 | Facebook | https://www.facebook.com/ | 3 | USA | +----+--------------+---------------------------+-------+---------+
SELECT Column examples
The following SQL statement select "name" and "country" column from the "Websites" table:
Examples
The output is:
SELECT * Examples
The following SQL statement selects all columns from the "Websites" table:
Examples
The output is:
The following command output:
Result set navigation
Most database software systems allow the use of programming functions to navigate in the result set, for example: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, and so on.
These columns programming functions that are not of this tutorial to explain the similar. To learn knowledge calls to access the data through a function, please visit our ADO tutorial or PHP tutorial .