Retrieving data from a single table Flashcards
True or False
SQL is case sensitive?
False
SQL is not case sensitive but keywords are usually CAPITALIZED.
USE
to select what database to query and must be terminated ;
SELECT
which columns to query or * for all columns
FROM
what table to query
MYSQL how to execute a high-lighted sub query (Windows)
shift + ctrl + enter
WHERE
used to filter the data on a conditional basis
True or False
This SQL query is in the correct order of operations?
USE
SELECT
FROM
WHERE
ORDER BY
True
ORDER BY
determines sort order ascending is the default
How do you make a comment in SQL
– this is a comment in SQL crtl + /
True or False
in SQL the FROM, WHERE, and ORDER BY clauses are optional?
True
What does this code produce?
USE
SELECT 1, 2
creates two columns 1 and 2
True or False
The order doesn’t matter in SQL?
False
order matters when querying a database
True or False
White space is ignored in SQL?
True
This code does what?
SELECT
last_name,
first_name,
points,
points + 10
FROM customers
selects columns last_name, first_name, and points columns from customers table and adds 10 points to the points column values then creates a column points + 10 to hold those values.
How do you create an alias in SQL
AS
FROM customers c
How would you change the order of operation in an expression?
with parathesis (points + 10) * 100
True or False
It’s a good idea to use an alias on SQL arithmetic expressions?
True
In SQL this “discount factor” is seen as a
string
SELECT DISTINCT does what?
removes or ignores duplicated values
What is the WHERE clause doing in this query?
- *SELECT** *
- *FROM** Customers
- *WHERE** points > 3000
filtering customers whose points are greater than 3000
What are the SQL comparison operators?
> greater than
>= greater than or equal
< less than
<= less than or equal
= equal
!=, <> not equal
What is the WHERE clause doing in this query?
SELECT *
FROM Customers
WHERE state = ‘VA’
filtering customers by the state of ‘VA’
What is the WHERE clause doing in this query?
- *SELECT** *
- *FROM** customers
- *WHERE** state = ! ‘VA’
filtering customers that are NOT in the state of ‘VA’
What is the WHERE clause doing in this query?
- *SELECT** *
- *FROM** customers
- *WHERE** birth_date > ‘1990-01-01’
filtering customer whose birth date is greater than 01-01-1990