Author | Message |
---|---|
se1k1h1mawar1
Posts: 121
|
Posted 20:34 Oct 28, 2015 |
Could somebody please suggest to me why this (please see below) is the output I get from the shown query? What I was trying to get as an output was what classes this student (student id = 300) has taken, and which grade s/he got in them... As you can see on the table at the very bottom, student whose id is 300 has only taken one class. Even a short one sentence suggestion would be greatly appreciated.
select c.title, e.student_id, g.letter, s.id as "section id" from enrol
--- ---- cs422=> select * from enrollment; Last edited by se1k1h1mawar1 at
20:35 Oct 28, 2015.
|
meishu
Posts: 6
|
Posted 20:55 Oct 28, 2015 |
I dunno if it'll fix it but you probably wanted |
cysun
Posts: 2935
|
Posted 20:58 Oct 28, 2015 |
You missed a join condition: the "e.section_id = e.section_id" should be "e.section_id = s.id". These types of errors are probably more obvious with the inner join syntax. |
se1k1h1mawar1
Posts: 121
|
Posted 21:00 Oct 28, 2015 |
I see! Thank you very much! |
cysun
Posts: 2935
|
Posted 21:00 Oct 28, 2015 |
Ha, looks like I'm too late. |
se1k1h1mawar1
Posts: 121
|
Posted 21:02 Oct 28, 2015 |
Thank you for your suggestion. It must be a good idea to get in a habit of using inner join syntax, at least I have enough experience with SQL! |