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.

Chapter 3<br />

104<br />

Category MemberId<br />

Thriller 5<br />

Thriller 10<br />

Romance 1<br />

War 6<br />

War 1<br />

Horror 10<br />

Sci-fi 4<br />

Historical 10<br />

War 11<br />

Horror 11<br />

Sci-fi 11<br />

Thriller 12<br />

War 12<br />

Historical 12<br />

Horror 13<br />

Sci-fi 13<br />

Romance 14<br />

Historical 14<br />

Note that there are 18 rows.<br />

Now execute the following <strong>SQL</strong> to add a new record to the Category table:<br />

INSERT INTO Category (CategoryId, Category)<br />

VALUES (7, ‘Comedy’);<br />

Next, re-execute the query:<br />

SELECT Category.Category, FavCategory.MemberId<br />

FROM FavCategory INNER JOIN Category<br />

ON FavCategory.CategoryId = Category.CategoryId;<br />

The re-execution provides the following results:

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

Saved successfully!

Ooh no, something went wrong!