Assignment009 (Joins)
Assignment009 (Joins)
Joins
1. Display all student and with their address from student and student_address tables.
select namefirst, address from student s, student_address a where s.id=a.studentID;
2. Display (namefirst, namelast, emailID, and student_qualification details) from student and
student_qualification relations.
select s.namefirst,s.namelast,s. emailID,sq.* from student s, student_qualifications sq where
s.id=sq.studentID;
3. Display (namefirst, namelast, emailID, college, and university) who have studied in 'Yale
University'. (Use student, and student_qualification relation)
select s.namefirst,s.namelast,s. emailID,sq.college,sq.university from student s,
student_qualifications sq where s.id=sq.studentID and university='Yale University';
4. Display all student details his phone details and his qualification details. (Use student,
student_phone and student_qualification relation)
select s.*, p.number , sq.name from student s join student_phone p join student_qualifications sq
on s.id = p.studentID and s.id = sq.studentID order by s.id;
5. Display (studentID, namefirst, namelast, name, college, university, and marks) whose name is ‘BE’.
(Use student, and student_qualification relation)
select sq.studentID, s.namefirst,s.namelast,s. emailID,sq.college,sq.university,sq.marks from
student s, student_qualifications sq where s.id=sq.studentID and name='BE';
6. Display the module name and the duration of the module for the batch “Batch1”.
select cb.name,m.name,m.duration from modules m inner join course_modules cm inner join
course_batches cb on cb.courseid =cm.courseid and cm.moduleid = m.id where cb.name ='batch1';
7. Display student information along with his batch details who have joined in “Batch1”.
select s.* , sb.batchID from student s inner join batch_students sb on s.id = sb.studentID where
sb.batchID = '1';
Infoway Technologies, 3rd Floor Commerce Centre, Rambaug Colony, Paud Road Pune 411038
8. Display module names for “PG-DAC” course.
select c.name ,group_concat(m.name) from course c join modules m join course_modules cm on
c.id = cm.courseID and m.id = cm.moduleID where c.name = 'PG-DAC' ;
10. Display (namefirst, namelast, phone number, and emailid) whose student ID is 13.
select distinct namefirst,namelast,emailID, number from student s , student_phone sp where s.id =
sp.studentID and s.id=13;
11. Display (namefirst and count the total number of phones a student is having) for all student.
select namefirst, count(number) "R1" from student s, student_phone sp where s.id=sp.studentID
group by namefirst;
12. Get student’s (namefirst, namelast, DOB, address, name, college, university, marks, and year).
select s.namefirst,s.namelast,s.DOB,sa.address,sq.name,sq.college,sq.university,sq.marks,sq.year
from student s inner join student_address sa inner join student_qualifications sq on s.id =
sa.studentID and s.id = sq.studentID;
13. Get (namefirst, namelast, emailID, phone number, and address) whose faculty name is
‘ketan’.
Select f.namefirst, f.namelast, f.emailID , fp.number, fa.address from faculty f inner join
faculty_phone fp inner join faculty_address fa on f.id = fp.facultyID and f.id = fa.facultyID where
namefirst = 'ketan';
15.Get all student details who have taken admission in ‘PG-DAC’ course.
17.Get all course name and module names which are taught in ‘PG-DAC’ course.
select distinct c.name , m.name from course c inner join modules m inner join course_modules cm
on cm.courseID = cm.moduleID where c.name = 'PG-DAC';
Infoway Technologies, 3rd Floor Commerce Centre, Rambaug Colony, Paud Road Pune 411038
19.Display the student detail who are ‘BE’ graduate.
select s.ID, s.namefirst,s.namelast,s. emailID from student s, student_qualifications sq where
s.id=sq.studentID and name='BE';
20.Display all distinct course detail, where module for every course is designed.
select c.name,group_concat(m.name) from course c inner join modules m inner join
course_modules cm on c.id=cm.courseID and m.id=cm.moduleID group by c.name;
Infoway Technologies, 3rd Floor Commerce Centre, Rambaug Colony, Paud Road Pune 411038