Workshop

The quiz and exercises are provided to help you solidify your understanding of the material covered today. Try to understand the quiz and exercise answers before continuing to tomorrow's lesson.

Quiz

1:What is the default type of join called?
A1: The default type of join is an INNER JOIN.
2:In the following statement, which are the best columns to index?
SELECT u.name, u.email, o.id, o.total_cost
  FROM users AS u
  LEFT JOIN orders AS o ON u.user_id = o.user_id
  WHERE o.order_id = 1002;
A2: The best columns to index are user_id on the users table, and user_id and order_id on the orders table.
3:

True or False: it is essential to use a table alias using AS when doing a join.

A3: False. An alias is only used to make SQL more compact.

Exercises ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.