0% found this document useful (0 votes)
4 views

Subquery and Join Gim

Uploaded by

chandrupriyan55
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Subquery and Join Gim

Uploaded by

chandrupriyan55
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

select * from student;

select * from department;

select * from faculty;

select s.sname,d.dname from student s,department d where s.dno=d.dno;

select max(marks),sname from student; //raise an error

select sname from student where marks=(select max(marks) from student);

select regno,sname from student where dno= (select dno from department ); //error

select regno,sname from student where dno= (select dno from department where dname='IT' );

//Display the students who studies in the department same as that of faculty Harshitha

select * from student where dno = (select dno from faculty where faculty_name='Harshitha');

//List the details of the student under Faculty Mala and Balakumar

select * from student where dno = (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Balakumar'); //error

select * from student where dno in (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Balakumar');

select * from student where dno in (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Balakumar');

select * from faculty;

select * from student where dno =any (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Balakumar');

select * from student where dno >any (select dno from faculty where faculty_name = 'Mala');

select * from student where dno <any (select dno from faculty where faculty_name = 'Raja');
select * from student where dno =any (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Raja');

select * from student where dno > any (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Raja');

select * from student where dno < any (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Raja');

select * from student where dno < all (select dno from faculty where faculty_name='Raja' or
faculty_name='Balakumar');

select * from faculty;

select * from student where dno > all (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Raja');

select * from faculty;

select * from student where dno <any (select dno from faculty where faculty_name = 'Mala' or
faculty_name='Balakumar');

insert into faculty values('CS001','Raja',2);

select * from student where dno =any (select dno from faculty where faculty_name = 'Mala') ;

select * from student where dno =all (select dno from faculty where faculty_name = 'Mala') ;

select * from student where dno >any (select dno from faculty where faculty_name = 'Mala') ;

select * from student where dno >all (select dno from faculty where faculty_name = 'Mala') ;

select dno from faculty where faculty_name='Raja' or faculty_name='Balakumar'


select * from student where dno < all (select dno from faculty where faculty_name='Raja' or
faculty_name='Balakumar');

select * from faculty;

select * from student where dno > any (select dno from faculty where faculty_name='Raja' or
faculty_name='Mala');

select * from student where dno > all (select dno from faculty where faculty_name='Raja' or
faculty_name='Mala');

select student.sname,department.dname from student,department where


student.dno=department.dno;

select * from student;

select * from department;

select student.sname,department.dname from student inner join department on


student.dno=department.dno;

select student.sname,department.dname from department inner join student on


student.dno=department.dno;

select department.dname,student.sname from department Left join student on


student.dno=department.dno;

select department.dname,student.sname from student Left join department on


student.dno=department.dno;

select * from department;

select * from student,department;

select department.dname,student.sname from department right join student on


student.dno=department.dno;

select department.dname,student.sname from department full outer join student on


student.dno=department.dno;
select * from student;

update student set marks=87 where regno='18IT003';

//self join display the details of the students who got same marks

SELECT A.sname AS student1, B.sname AS student2, A.marks FROM student A, student B wHERE
A.regno <> B.regno AND A.marks = B.marks;

select sname from student where marks= any(select marks from student group by marks having
count(*) >1);

Select s.sname ,s1.marks from student s, student s1 where s.marks = s1.marks and s.sname !=
s1.sname;

You might also like