SQL SELECT
The SQL SELECT clause selects data from one or more database tables and/or views. In its basic form the SQL SELECT syntax looks like this:
Let's have a look at the SELECT SQL statement above. The first part starts with the SELECT clause followed by a list of columns separated by commas. This list of columns defines which columns we are selecting data from. The second part of our SQL SELECT starts with the FROM clause followed by name of table from where we are extracting data.
We will use a table called Weather with 3 columns - City, AverageTemperature and Date, to give a real world SQL SELECT example:
City | AverageTemperature | Date |
New York | 22 C | 10/10/2005 |
Seattle | 21 C | 10/10/2005 |
Washington | 20 C | 10/10/2005 |
To select all cities from the above table, we will use this SQL SELECT statement:
City |
New York |
Seattle |
Washington |
If we want to select all the data (all columns) from the Weather table we can do it with the following SQL SELECT:
The * replaced the column list following the SELECT SQL clause, thus instructing the SQL interpreter to return all columns.
Tweet