Ian H
Ian H

Reputation: 1

Oracle Join three tables: JOIN USING

I'm currently working through the Oracle DB Programming Modules and one of the questions is: Join DJs on Demand d_play_list_items, d_track_listings, and d_cds tables with the JOIN USING syntax. Include the song ID, CD number, title, and comments in the output.

What I tried was several variations of this:

SELECT p.song_id, t.cd_number, c.title, p.comments
FROM d_play_list_items p JOIN d_track_listings t JOIN d_cds d
USING (song_id);

I keep getting the error message: ORA-00905: missing keyword but I've got no idea what I'm doing wrong.

If someone could help me work through this I'd appreciate it a lot.

-Howie

Upvotes: 0

Views: 404

Answers (2)

Haileyesus Ephrem
Haileyesus Ephrem

Reputation: 1

SELECT 
Song_ID, 
CD_Number, 
Title, 
Comments 
FROM D_Play_List_Items p JOIN D_Track_Listings t 
USING (Song_Id) JOIN D_Cds d USING (Cd_Number); 

Upvotes: -2

Dave Costa
Dave Costa

Reputation: 48111

Each JOIN requires a corresponding ON or USING clause; in this case, given the requirements, a USING clause.

So you would need to add a USING clause for the first join:

FROM d_play_list_items p
JOIN d_track_listings t USING (?)
JOIN d_cds d USING (?)

It's not clear from your question exactly what the join columns should be in each case.

Upvotes: 3

Related Questions