In this lab, you'll practice your knowledge of JOIN
statements, using various types of joins and various methods for specifying the links between them.
You will be able to:
- Write SQL queries that make use of various types of joins
- Compare and contrast the various types of joins
- Discuss how primary and foreign keys are used in SQL
- Decide and perform whichever type of join is best for retrieving desired data
In almost all cases, rather than just working with a single table you will typically need data from multiple tables. Doing this requires the use of joins using shared columns from the two tables.
In this lab, you'll use the same customer relationship management (CRM) database that you saw from the previous lesson.
Import the necessary packages and connect to the database 'data.sqlite'
.
# Your code here
Hint: join the employees and offices tables.
# Your code here
Hint: Combine the employees and offices tables and use a group by.
# Your code here
# Answers will vary
# Example: Display the htmlDescription and employee's first and last name for each product that each employee has sold
# Your code here
# Your code here
# Your code here
# Your code here
# Your code here
Congrats! You practiced using join statements and leveraged your foreign keys knowledge!