SQL SELECT
Jump to navigation
Jump to search
Internal
Overview
A query consists in at least one (SELECT
) and at most six categories of clauses:
SELECT [one or more things] FROM [one or more places] WHERE [one or more conditions apply] GROUP BY [...] HAVING [...] ORDER BY [...];
Almost every query will include at least three of these clauses (SELECT
, FROM
and WHERE
).
Upon execution, an SQL query returns a result set.
Select all (possibly across multiple tables) then filter and discard with where.
Example
SELECT id, name FROM person WHERE id = 1;
The following query:
SELECT;
is valid, it returns one empty row.
Clauses
SELECT
SELECT [one or more things] ...
SELECT
specifies which columns from the FROM
sources need to be retrieved.
FROM
FROM [one or more places]
The "places" we select from can be:
- permanent
- derived
- temporary
- virtual(view)
Table alias.