Querying Data With The SELECT Statement: Jon Flanders
Querying Data With The SELECT Statement: Jon Flanders
Statement
Jon Flanders
@jonflanders www.jonflanders.com
You can think of a SELECT
statement as a question you
are asking the database.
Example Questions
{
SELECT ‘Hello’,‘World’;
{
SELECT LIST
Most of the time it contains a list of columns
from a table you want to query.
The SELECT
Then, a FROM clause is required.
List After every column comes a comma.
Except: no comma after the last column.
SELECT <COLUMN_NAME>, <COLUMN_NAME> FROM <TABLE_NAME> ;
BAD PRACTICE!
On my screen, these are both not
centered, but are about 2/3 down the
slide. Also, font sizes are different on
either side.
Good Practice
Aliasing the Table Name
Best Practice
Ways to Constrain the Number of Results
Jon
Jon
Fritz
What are the first names of all the
people I know? Shannon
Jason
Jason
Brian
SELECT p.first_name FROM person p ;
Brian
DISTINCT
first_name
Jon
Fritz
Shannon
What are all unique first names of
the people I know? Jason
Brian