CadencePlus Solutions

SELECT and FROM

SQL is the language used to ask questions of a relational database: a collection of related tables. SELECT chooses the output; FROM names its source.

Tables, rows and columns

A table stores records of the same kind. In customers, one row represents one customer. customer_name and country are columns describing that customer. This row meaning is the table’s grain.

Choose the output

List column names after SELECT, separated by commas. Their order becomes the output column order. Selecting a column reads it; it does not change the source table.

Name the source

FROM customers identifies the source table. SQL keywords such as SELECT and FROM are not case-sensitive. Text comparisons have rules that vary by database; we will explore those rules with text filters.

Explore carefully

SELECT * returns every column. It is useful for a quick inspection, but explicit columns make reports easier to review and less vulnerable to schema changes. End a statement with a semicolon; use -- for a line comment.