0% found this document useful (0 votes)
56 views5 pages

22 - Exp 8

The document describes an experiment to implement different types of joins in SQL, including inner joins, left outer joins, right outer joins, and full outer joins. It provides examples of creating tables with departments and employees, inserting data into the tables, and performing selects to view the data and results of joins.

Uploaded by

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

22 - Exp 8

The document describes an experiment to implement different types of joins in SQL, including inner joins, left outer joins, right outer joins, and full outer joins. It provides examples of creating tables with departments and employees, inserting data into the tables, and performing selects to view the data and results of joins.

Uploaded by

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

Name : Anushka Karhadkar

Div : D10B
Roll No : 22
EXPERIMENT NO. 8
Aim : To implement joins in SQL.

Theory:
Sql joins clause is used to combine records from two or more tables
in a database. a join is a means for combining fields from two tables
by using values common to each.
Different types of SQL Joins :

Here are the different types of the JOINs in SQL:

 (INNER) JOIN: Returns records that have matching values in


both tables
 LEFT (OUTER) JOIN: Returns all records from the left table, and
the matched records from the right table
 RIGHT (OUTER) JOIN: Returns all records from the right table,
and the matched records from the left table
 FULL (OUTER) JOIN: Returns all records when there is a match
in either left or right table

INPUT :

CREATE TABLE DEPT(

dep_name VARCHAR(10) NOT NULL,

dep_id INTEGER NOT NULL,

dep_location VARCHAR(10),
PRIMARY KEY(dep_id));

INSERT INTO DEPT

VALUES ('FINANCE','1001','SYDNEY');

INSERT INTO DEPT

VALUES ('AUDIT','2001','MELBOURNE');

INSERT INTO DEPT

VALUES ('MARKETING','3001','PERTH');

INSERT INTO DEPT

VALUES ('PRODUCTION','4001','BRISBANE');

SELECT * FROM DEPT;

CREATE TABLE Employee(

Emp_id INTEGER NOT NULL,

Emp_name VARCHAR(12),

Job_name VARCHAR(12),

Manager_id INTEGER,

Hiredate CHAR (10),

Salary numeric(7,2),

commision numeric(7,2),

dept_id INTEGER,
CONSTRAINT fk_dept

FOREIGN KEY(dept_id)

REFERENCES DEPT(dep_id));

INSERT INTO Employee

VALUES ('68319','Kayling','president','68319','1991-11-
18',6000,400,'1001');

INSERT INTO Employee

VALUES ('66928','blaze','manager','68319','1991-05-
01',2750,NULL,'3001');

INSERT INTO Employee

VALUES ('67832','clare','manager','68319','1991-06-
09',2550,NULL,'1001');

INSERT INTO Employee

VALUES ('65646','jonas','manager','68319','1991-04-
02',2957,NULL,'2001');

INSERT INTO Employee

VALUES ('67858','scarlet','analyst','65646','1991-04-
19',3100,NULL,'2001');

INSERT INTO Employee

VALUES ('69062','frank','analyst','65646','1991-12-
03',3100,NULL,'2001');

INSERT INTO Employee

VALUES ('63679','sandrine','clerk','69062','1990-12-
18',900,NULL,'2001');
INSERT INTO Employee

VALUES ('64989','adelyn','salesman','66928','1991-02-
20',1700,400,'3001');

INSERT INTO Employee

VALUES ('65271','wade','salesman','66928','1991-02-
22',1350,500,'3001');

INSERT INTO Employee

VALUES ('66564','madden','salesman','66928','1991-09-
22',1350,1500,'3001');

INSERT INTO Employee

VALUES ('68454','tucker','salesman','66928','1991-09-
08',1600,0,'3001');

INSERT INTO Employee

VALUES ('68736','adnres','clerk','67858','1997-05-
23',1200,NULL,'2001');

INSERT INTO Employee

VALUES ('69324','marker','clerk','67832','1992-01-
23',1400,NULL,'1001');

select * FROM Employee;

OUTPUT :

You might also like