0% found this document useful (0 votes)
15 views3 pages

Assignment009 (Joins)

Uploaded by

helloww659
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Assignment009 (Joins)

Uploaded by

helloww659
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment

Mar24/ DBT/ 009


Database Technologies
Diploma in Advance Computing
March 2024

Joins

USE student_phone, student_address, faculty_phone, faculty_address, batch_students, course_batches,


student_qualifications, faculty_qualifications, course_modules, modules, faculty, student, course,
student_cards, and student_order relation to solve the following queries.

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' ;

9. Display namefirst, namelast, and batch name for all students.


select namefirst,namelast ,cb.name from student s , course_batches cb ,batch_students bs where
s.id = bs.studentID and cb.id = bs.batchID;

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';

14. Get(course name and batch name)for all courses.

select c.name , cb.name from course c , course_batches cb where c.id = cb.courseID;

15.Get all student details who have taken admission in ‘PG-DAC’ course.

select * from student , course where name = 'PG-DAC';

16.Get all course details which had started on ‘2016-02-01’.


select c.name , cb.starton from course c inner join course_batches cb on c.id = cb.courseID where
cb.starton = '2016-02-01';

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';

18.Display how many modules are taught in each course.


select group_concat(m.name) , c.name from modules m inner join course c inner join
course_modules cm on c.id = cm.courseID and m.id = cm.moduleID group by name;

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;

21.Display studentID who have more than 2 phone numbers.


select s.id , sp.number from student s inner join student_phone sp on s.id = sp.studentID where
sp.number > 2;

22.Display the courses where ‘JAVA1’ is taught.


select group_concat(c.name),m.name from course c inner join modules m inner join
course_modules cm on c.id=cm.courseID and m.id=cm.moduleID where m.name = 'java1';

23.Display all student who have taken admission in 6 months course.


select distinct s.namefirst , c.duration from student s join course c join course_batches cs join
batch_students bs on s.id = bs.studentID and cs.id = bs.batchID and c.id = cs.courseID where
c.duration = 6;

24. Write a query to display the output in the following manner.


'saleel', 'Aadhaar, Driving Licence, PAN, Voter ID, Passport, Debit, Credit'
Arrange the data is ascending order of nameFirst.
select namefirst, group_concat(name) from student s inner join student_cards sc on s.id =
sc.studentID group by namefirst;

25. Write a query to display the output in the following manner.


'ruhan', 'DBDA, PG-DAC, Pre-DAC'
select s.namefirst ,group_concat(c.name) from student s join course c join course_batches cs join
batch_students bs on s.id = bs.studentID and cs.id = bs.batchID and c.id = cs.courseID group by
namefirst;

Infoway Technologies, 3rd Floor Commerce Centre, Rambaug Colony, Paud Road Pune 411038

You might also like