WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL SELECT Statement

SELECT Statements are used to select data from a database.


SQL SELECT statement

SELECT statement is used to select data from the database.

Results are stored in a result table, called a result set.

SQL SELECT syntax

SELECT column_name , column_name
FROM table_name ;

and

SELECT * FROM table_name ;


Demo database

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

Here is the data from the "Websites" table:

+----+--------------+---------------------------+-------+---------+
| id | name         | url                       | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1  | Google       | https://www.google.cm/  | 1     | USA     |
| 2  | Indiatimes.com          | https://www.Indiatimes.com/ | 9    | IN      |
| 3  | zomato      | http://www.zomato.com/  | 83  | IN      |
| 4  | indiamart          | http://indiamart.com/       | 33    | IN      |
| 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:

Examples

SELECT name,country FROM Websites;

SELECT * Example

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

Examples

SELECT * FROM Websites;

Navigation in the result set

Most database software systems allow programmatic functions to navigate in the result set, such as: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, and so on.