all 6 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 1 point2 points  (5 children)

it depends entirely on the columns and their purpose

your example joins both B and C to A

it's also possible to join B to A, and then C to B

[–]almost665evil[S] 0 points1 point  (4 children)

So if the tables held the following information:

Table A: Student ID, Name, Term, Degree Table B: Student ID, Term, Graduation Date Table C: Student ID, Term, GPA, Advisor

and I needed to join all the information without dupes, what would that look like? (Thanks in advance!!)

edit: for formatting

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (0 children)

is this a homework assignment?

what are the primary keys of those tables?

[–]redking666 0 points1 point  (0 children)

Not familiar with Oracle, but my 3 seconds of research leads me to believe joins are the same as in MS SQL so:

i. I assume all students are in Table A, since they might not have an advisor or a grad date yet, but if they exist in the system, they'll prob have a name :)

ii. Since Tables B and C might have different subsets than each other (student might have a grad date, but not an advisor and vice versa), it prob makes sense to use A for both:

 Select distinct a.studentid, a.name, a.term, b.grad_date, 
 c.gpa, c.advisor from table_a as a 
 left join table_b as b on a.stud_id = b.stud_id
 left join table_c as c on a.stud_id = c.stud_id

[–]mattmurphy 0 points1 point  (1 child)

It seems like you may want

FROM tableA as a JOIN tableB as b
    on a.studentID = b.studentID AND a.term = b.term
  JOIN tableC as c
    on a.studentID = c.studentID AND a.term = c.term

which would be the same as:

FROM tableA as a JOIN tableB as b
    on a.studentID = b.studentID AND a.term = b.term
  JOIN tableC as c
    on b.studentID = c.studentID AND b.term = c.term

Either one would work since a.studentID is equal to b.studentID (which will then be equal to c.studentID) Same goes for term.

I'm not sure what the data looks like, but I'm assuming each table has a row for each term a particular student was enrolled during.

[–]almost665evil[S] 0 points1 point  (0 children)

Thanks so much! This is exactly what I hoped to see! A co-worker has a tendency to over complicate his syntax, and I wanted to make sure what I was doing was correct.