Creating a Join

Creating a join is very simple. You must specify all the tables to include 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

Let's take a look at the preceding code. The SELECT statement starts in the same way as all the statements you've look at ...

Get Sams Teach Yourself SQL in 10 Minutes 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.