| SELECT column_name(s)
FROM table_name; |
and
| SELECT * FROM table_name; |
See the samples section below for an explanation of the Select statement.
The SELECT statement is used to retrieve data from a database.
The result is stored in a result table.
In this SQL sample we will use the database table ‘tblCompany’.
| Company_ID |
CompanyName |
Address |
Town |
| 1 |
SQL Sample |
1 Sample St |
Hamburg |
| 2 |
SQL Code Land |
2 Code Rd |
Hamburg |
| 3 |
Sample Code World |
66 SQL St |
Curry |
| 4 |
SQL Reference Ltd |
34 Reference St |
Pisa |
In order to retrieve the rows of the columns called ‘CompanyName’ and ‘Town’ from the table above.
Use the SELECT statement below:
| SELECT CompanyName,Town FROM tblCompany; |
The table of results will look like this:
| CompanyName |
Town |
| SQL Sample |
Hamburg |
| SQL Code Land |
Hamburg |
| Sample Code World |
Curry |
| SQL Reference Ltd |
Pisa |
In this SQL sample we will use the database table ‘tblCompany’.
| Company_ID |
CompanyName |
Address |
Town |
| 1 |
SQL Sample |
1 Sample St |
Hamburg |
| 2 |
SQL Code Land |
2 Code Rd |
Hamburg |
| 3 |
Sample Code World |
66 SQL St |
Curry |
| 4 |
SQL Reference Ltd |
34 Reference St |
Pisa |
In order to retrieve the rows of the columns called ‘CompanyName’ and ‘Town’ from the table above.
Use the SELECT statement below:
| SELECT * FROM tblCompany; |
The table of results will look like this:
| Company_ID |
CompanyName |
Address |
Town |
| 1 |
SQL Sample |
1 Sample St |
Hamburg |
| 2 |
SQL Code Land |
2 Code Rd |
Hamburg |
| 3 |
Sample Code World |
66 SQL St |
Curry |
| 4 |
SQL Reference Ltd |
34 Reference St |
Pisa |
Related SQL Sample Code: