• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

Joining three tables

I need help joining three tables with the JOIN USING syntax. Here is what I have could you please tell me what I'm overlooking?

Select song_id, cd_number, title, comments
From d_play_list_items  JOIN d_cds
USING (cd_number)
JOIN d_track_listings

The tables d_play_list_items & d_track_listings share the song_id column.
The tables d_track_listings & d_cds share the cd_number column.

When I submit this query it tells me that it is missing keyword
0
dc0819
Asked:
dc0819
2 Solutions
 
Neil RussellTechnical Development LeadCommented:
Try

Select song_id, cd_number, title, comments
From d_play_list_items  
JOIN d_track_listings
USING song_id
JOIN d_cds
USING (cd_number)


0
 
dc0819Author Commented:
Still showing missing keyword
0
 
AkenathonCommented:
Select song_id, cd_number, title, comments
From d_play_list_items  
JOIN d_track_listings USING (song_id)
JOIN d_cds USING (cd_number)

You need parentheses around the USING fields
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Neil RussellTechnical Development LeadCommented:
Oops I missed the brackets on the one line, your right. thank you.
0
 
dc0819Author Commented:
That worked - I overlooked the brackets as well.

Thanks
0
 
South ModModeratorCommented:
I've reopened your question in order to award points more equitably.

Since both Experts provided a substantial portion of this solution, I've split the points evenly between them. In cases like this, where one Expert (Akenathon) corrects the posting of another, it's customary to accept both comments. In fact, the second Expert (in this case, Akenatho) really should recognize that they are mading edits to the suggestion of an earlier Expert by posting something like this:

"Neilsr's answer is almost correct, except you must include parentheses around the USING fields"

Select song_id, cd_number, title, comments
From d_play_list_items  
JOIN d_track_listings USING (song_id)
JOIN d_cds USING (cd_number) "

This recognizes the earlier work of the other Experts while still providing assistance to the author.

SouthMod
EE Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now