From the course: Introduction to SQLite

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Combining multiple tables with JOINs

Combining multiple tables with JOINs - SQLite Tutorial

From the course: Introduction to SQLite

Combining multiple tables with JOINs

- [Instructor] So far, most of the queries you've seen have retrieved data from just one table, and most of the time you'll be working with data from multiple tables, so it's important to join them properly to get the results you want. When you learned about foreign keys earlier in this course, you got a glimpse of the JOIN clause. This allows you to link multiple tables when you query them together. Here's an example that gets the count of invoice IDs for every customer who has a company name associated with their record in the customer table. The WHERE company is NOT NULL clause takes care of only selecting customers with company names. You may be wondering what happens when you query two tables without a JOIN clause. In some cases this is useful, but in general, you'll get results that combine data from tables incorrectly. Here's what happens when we try the preceding query without the JOIN clause. Instead of the…

Contents