mthomp81 mthomp81 - 1 month ago 9
SQL Question

Joining three tables in Oracle11g SQL

Normally, this wouldn't be a problem for me, but 1. My instructor never taught us how to join three tables like this and 2. It wasn't even covered on this week's assignment. But because these databases aren't in Oracle interface database that we normally use, I have no way of even doing trial and error.

I have three tables. The contents aren't important to the question.
The first table is STUDENTS, with columns LAST_NAME, SID, and MID (two of the MID cells have NULL values here).
Second table is COURSES, with columns COURSES (don't know why whoever designed this question decided to name it the same as the table) and CID (I'm assuming that's a primary key)
Third table is ENROLLED, with columns SID and CID.

I'm asked the following question
"Use the three tables shown above to answer the following questions:
a. What kind of join would you use to join all three tables?
Write the syntax that would produce the desired result.
b. Name two tables that could be used to retrieve data from a natural join.
Write the syntax that would produce the desired result."

I'm stuck on this one. Internet hasn't been much help so far, not even Oracle's materials. We learned about joining, but we never joined more than two tables. Any help would be appreciated.

GVR GVR
Answer

STUDENTS, with columns LAST_NAME, SID, and MID COURSES, with columns COURSES and CID ENROLLED, with columns SID and CID.

a table can be joined with another table if both the table have one column in common. so here STUDENTS TABLE can be joined with ENROLLED,

ENROLLED.SID =STUDENTS.SID

and COURSES can be joined with ENROLLED

ENROLLED.CID=COURSES.CID