20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note that MS Access insists that you place brackets around joins where there are multiple joins, so you<br />

need to rewrite the preceding <strong>SQL</strong> as follows:<br />

SELECT FirstName, LastName, Category.Category<br />

FROM (MemberDetails INNER JOIN FavCategory<br />

ON MemberDetails.MemberId = FavCategory.MemberId)<br />

INNER JOIN Category<br />

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

ORDER BY LastName, FirstName;<br />

Selecting Data from Different Tables<br />

Notice the inner join on the MemberDetails and FavCategory tables. The results of that inner join are<br />

then joined with the Category table. This query produces the following results:<br />

FirstName LastName Category<br />

Stuart Dales Thriller<br />

Stuart Dales War<br />

Stuart Dales Historical<br />

Stuart Dales Comedy<br />

William Doors Sci-fi<br />

William Doors Horror<br />

Steve Gee Sci-fi<br />

Steve Gee Comedy<br />

Jamie Hills War<br />

Jamie Hills Sci-fi<br />

Jamie Hills Horror<br />

Jenny Jones War<br />

Jenny Jones Comedy<br />

John Jones Thriller<br />

Doris Night Romance<br />

Doris Night Historical<br />

Susie Simons Historical<br />

Susie Simons Horror<br />

Susie Simons Thriller<br />

Katie Smith Romance<br />

Katie Smith War<br />

211

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

Saved successfully!

Ooh no, something went wrong!