Creating a Join

Creating a join is very simple. You must specify all the tables to be included and how they are related to each other. Look at the following example:

SELECT vend_name, prod_name, prod_price
FROM Vendors, Products
WHERE Vendors.vend_id = Products.vend_id;
vend_name                  prod_name                prod_price
-----------------------    ---------------------    ----------
Doll House Inc.            Fish bean bag toy        3.4900
Doll House Inc.            Bird bean bag toy        3.4900
Doll House Inc.            Rabbit bean bag toy       3.4900
Bears R Us                 8 inch teddy bear         5.9900
Bears R Us                 12 inch teddy bear        8.9900
Bears R Us                 18 inch teddy bear        11.9900
Doll House Inc.            Raggedy Ann               4.9900
Fun and Games              King doll                 9.4900
Fun and Games              Queen doll                9.4900

Let's take a look at the preceding code. The SELECT statement ...

Get Sams Teach Yourself SQL in 10 Minutes, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.