20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Summary<br />

Selecting Data from Different Tables<br />

This chapter advanced your knowledge of joins far beyond the simple inner joins covered in Chapter 3.<br />

You can now answer questions that were impossible to answer with a basic inner join. The chapter<br />

started off by revisiting inner joins. It looked at how to achieve multiple joins with multiple conditions.<br />

Additionally, this chapter covered the difference between equijoins, which use the equals operator, and<br />

non-equijoins, which use comparison operators such as greater than or less than.<br />

The chapter then turned to outer joins. Whereas inner joins require the ON condition to return true,<br />

outer joins don’t. The chapter covered the following types of outer joins:<br />

❑ Left outer joins, which return rows from the table on the left of the join, whether the ON clause is<br />

true or not<br />

❑ Right outer joins, which return rows from the table on the right, regardless of the ON clause<br />

❑ Full outer joins, which return rows from the tables on both sides, even if the ON clause is false<br />

In the final part of the chapter, you learned about how you can use the UNION statement to combine the<br />

results from two or more SELECT queries into just one set of results.<br />

The next chapter introduces the topic of subqueries and shows you how you can include another query<br />

inside a query.<br />

Exercises<br />

1. List pairs of people who share the same favorite film category. The results set must include the<br />

category name and the first and last names of the people who like that category.<br />

2. List all the categories of film that no one has chosen as their favorite.<br />

233

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!