Difference between revisions of "SELECT Reference"
Jump to navigation
Jump to search
(Revert vandalisms) |
|||
Line 18: | Line 18: | ||
*The SELECT line determines which columns to show - in this case <code>name</code> and <code>population</code>, both of which are columns of the bbc table. | *The SELECT line determines which columns to show - in this case <code>name</code> and <code>population</code>, both of which are columns of the bbc table. | ||
*The WHERE clause determines which rows to show | *The WHERE clause determines which rows to show | ||
*The SELECT statement may involve data from more than one table using a [[JOIN]] or a [[UNION]]. | |||
The SELECT statement may involve data from more than one table using a [[JOIN]] or a [[UNION]]. | *SELECT statements may nested - that is the output from one SELECT may be the input to another SELECT. | ||
*The output from a SELECT may be added to another table using [[INSERT .. SELECT]] | |||
SELECT statements may nested - that is the output from one SELECT may be the input to another SELECT. | |||
The output from a SELECT may be added to another table using [[INSERT .. SELECT]] |
Revision as of 11:48, 18 June 2013
The SELECT command is used to show data from a database.
The output from a SELECT statement is always a grid - with a number of rows and a number of columns.
Simple SELECT
The simplest SELECT commands involve a single table:
SQL | Result | ||||||||
---|---|---|---|---|---|---|---|---|---|
SELECT name, population
FROM bbc
WHERE region='North America'
|
|
- The SELECT line determines which columns to show - in this case
name
andpopulation
, both of which are columns of the bbc table. - The WHERE clause determines which rows to show
- The SELECT statement may involve data from more than one table using a JOIN or a UNION.
- SELECT statements may nested - that is the output from one SELECT may be the input to another SELECT.
- The output from a SELECT may be added to another table using INSERT .. SELECT