I have these 2 tables:
master (major, SID, fee)
Biology, 13578, $500
Physics, 12460, $400
student (major, SID, fname, lname, startDate, lastDate)
Science, 73589, Steven, Archer, 2010-09-02, null
Biology, 13578, Stacy, Diaz, 2009-09-02, null
Sociology, 21749, Gavin, Wall, 2011-01-05, null
Physics, 12460, Pat, Dunn, 2012-09-02, null
I have to make a query where it shows the information of all master students grouped by their major and their fee.
I tried it this way:
select * from from master, student
where master.SID=student.SID AND master.major=student.major
group by student.SID;
But this will make SID and major info to show twice:
Biology, 13578, Stacy, Diaz, 2009-09-02, null, Biology, 13578
Physics, 12460, Pat, Dunn, 2012-09-02, null, Physics, 12460
so now I have this:
select distinct student.sid, student.eid, fname, lname, startDate, lastDate, fee
from from master, student
where master.SID=student.SID AND master.major=student.major
group by student.SID;
which will give:
Biology, 13578, Stacy, Diaz, 2009-09-02, null
Physics, 12460, Pat, Dunn, 2012-09-02, null
But I'm wondering if there's a way to not specify which SID or major to select. I want it to select all but it deletes duplicates.
Sorry if this seems easy, I'm still a beginner in mysql