Chapter 9. Advanced Queries

In Chapter 4, “Retrieving Data: Simple Queries,” you learned how to perform simple database queries using SQL.This Chapter deals with more advanced queries, including table joins—one of the most powerful features of SQL.

Joins

Relational databases have the capability to split data across several tables in a structured way so data is never repeated. In general, a column in one table that can uniquely identify a particular row is known as a primary key and a column in another table that references that table’s primary key is known as a foreign key.

Consider the tables in the sample database. The book table has a primary key named book_id, which is a unique numeric value for each book record in the table. Similarly, the primary ...

Get MySQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.