You are on page 1of 5

DBMS LAB EXPIREMENT-7

Jenma Maria Binoy


ROLLNO 34 S7 INTMCA
Experiment: 7

AIM

• SQL queries to implement Join Operations.

QUERY:

1. Create tables as given below & perform the following join operations. o Inner Join,
Left Join, Right Join & Cross Join.

STUDENT MARKS

ID NUMBER PK ID NUMBER PK
SNAME VARCHAR S_ID NUMBER FK , STUDENT(ID)
GENDER VARCHAR MARK NUMBER

QUERY:

SQL> create table student(id number(3) primary key,sname varchar(15),gender varchar(15));

SQL> insert into student values(111,'David','Male');


SQL> select s.id,s.sname,s.gender,m.id,m.s_id,m.mark from student s inner join marks m on
s.id=m.s_id;

SQL> select s.id,s.sname,s.gender,m.id,m.s_id,m.mark from student s left join marks m on


s.id=m.s_id;

SQL> select s.id,s.sname,s.gender,m.id,m.s_id,m.mark from student s right join marks m on


s.id=m.s_id;
SQL> select s.id,s.sname,s.gender,m.id,m.s_id,m.mark from student s cross join marks m ;

2. Create EMPLOYEE TABLE & DEPARTMENT TABLE as given below.

SQL> create table employe(empno number(2) primary key,ename varchar(15),job


varchar(15),deptno number(2),salary number(6)) ;
SQL> insert into employe values(1,'Mittu','AP',1,300000);
SQL> create table department(deptno number(2) ,dname varchar(12),location varchar(25));
SQL> insert into department values(1,'MCA','New York');

Q1. Display the details of employee, departments such that the departments are same in both the
employee and department tables.
SQL> select e.empno,e.ename,e.job,e.salary,d.dname,d.location from employe e inner join
department d on e.deptno=d.deptno;

Q2. Display the empno,ename & location of employees who works in MCA & CSE departments.

SQL> select e.empno,e.ename,d.location from employe e inner join department d on


e.deptno=d.deptno where d.dname='MCA' or d.dname='CSE';

Q3. Display the empno,ename & job of employee who works in ‘Dallas’.

SQL> select e.empno,e.ename,e.job from employe e inner join department d on


e.deptno=d.deptno where d.location='Dallas';

You might also like