O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inner Joins

An inner join, or equijoin, is a join that uses a condition to specify a relationship between tables in which a column in one table is equal to another column in the other table. In the previous lesson, you learned how to do this using the WHERE clause.

The alternative syntax uses the keyword phrase INNER JOIN to specify a table to join to and the keyword ON to specify a conditional clause that indicates the relationship between the tables.

The following example reproduces the query from Lesson 11, “Joining Tables,” to retrieve all the customer contact information:

mysql> SELECT name,
    -> CONCAT(last_name, ', ', first_name) as contact_name
    -> FROM customers
    -> INNER JOIN customer_contacts
    -> ON customers.customer_code =
    ->    customer_contacts.customer_code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required