In MySQL what is the default JOIN type?
inner join
What two types of JOIN’s are available in MySQL?
inner and outer JOIN’s
When selecting a column that’s present on multiple tables what should be prefixed when making a selection?
the table name or alias
(customer_id being present on multiple tables)
SELECT orders.customer_id, first_name, last_name
This code has a lot of repeat words, refactor it. Using alias.
True or False
These aliases would return the same results
FROM orders AS o
FROM orders o
True
What are the two aliases being used in this query?
o and c
True or False
When querying multiple tables, it’s best to:
True
True or False
To join multiple tables in different databases you’d prefix the database in the JOIN statement?
True
Identify the other database being used in this query?
sql_inventory
True or False
In MySQL, it’s possible to JOIN a table with itself? What is the benefit?
USE sql_hr;
True
Good for making organizational charts shows who reports to whom if the data is available.
How many tables are being joined in this query?
3 tables
orders
customers
order_statuses
In MySQL what is a composite primary key?
A table where two columns define the primary key.
This query is an example of what?
Joint compound condition, more than two columns are the primary keys.
Refactor this query using implicit join syntax
What is a potential peril using an implicit join syntax?
If you forget the WHERE clause you’d end up with a funky cross-join.
True or False
It’s better to use an implicit join statement when executing queries?
True
What two types of OUTER JOINS are available in slq?
LEFT
RIGHT
True or False
In MySQL a LEFT JOIN will include all the data in the left table regardless of any other condition being met?
True
What is the left table in this query?
customers table
What is the right table in this query?
orders table
same results returned by an inner default join in this instance
True or False
In MySQL, the position of the left & right tables in outer joins can change the data being returned.
True
True or False
In MySQL the OUTER and INNER keywords are required?
False
JOIN - default inner
LEFT - outer
RIGHT - outer
What is the power of an OUTER JOIN?
Returns result from the left table regardless if the join condition is met. Much like returning null values from a query on products sold and shipped.
As a rule of thumb it’s best practice to avoid RIGHT JOINS in MySQL?
True
Just switch which table is on the left and use a LEFT JOIN