Exercise: Creating a simple join between two tables using the designer

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> SQL  (115 exercises)
Topic ==> Basic joins  (6 exercises)
Level ==> Relatively easy
Course ==> Introduction to SQL
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

If you haven't already done so, run the script in the folder above to generate the Doctor Who database.

Right-click in a new query and use the designer to create a query linking these two tables:

Two tables

Each episode is linked to the person who wrote it.

Add columns and filters to your query so that it shows who wrote the "special" episodes (there should be 13 listed out, of which the first few in alphabetical order are shown below):

First few episodes

The first few episodes containing the word special in the title.

For the filter, use the criteria LIKE '%special%'.

Now tidy up the generated query so that it looks more like proper SQL!  Here's a suggestion:

-- the query, tidied up

SELECT

tblAuthor.AuthorName,

tblEpisode.Title,

tblEpisode.EpisodeType

FROM

tblAuthor

INNER JOIN tblEpisode ON

tblAuthor.AuthorId = tblEpisode.AuthorId

WHERE

tblEpisode.EpisodeType LIKE '%special%'

ORDER BY

tblEpisode.Title

Save this query as No joins necessary, then close it down.

This page has 0 threads Add post