Cover by Lynn Beighley

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Chapter 8. Joins and Multi-Table Operations: Can’t we all just get along?

image with no caption

Welcome to a multi-table world. It’s great to have more than one table in your database, but you’ll need to learn some new tools and techniques to work with them. With multiple tables comes confusion, so you’ll need aliases to keep your tables straight. And joins help you connect your tables, so that you can get at all the data you’ve spread out. Get ready, it’s time to take control of your database again.

Still repeating ourselves, still repeating...

Greg noticed the same values for status, profession, interests, and seeking popping up again and again.

image with no caption

Prepopulate your tables

Wouldn’t it make sense to have a set list of values in some of the tables?

Having many duplicate values will make it easy to prepopulate the status, profession, interests, and seeking tables. Greg wants to load up those four tables with the values already in his old my_contacts table.

First he needs to query his table to find out what’s already in there. But he doesn’t want an enormous list of duplicate values.

image with no caption

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required