Creating employee and projects table and performin inner join equi join and outer join left join right join full join

** Create table**

Create table employee (employeeid int,fname varchar2(10),lname varchar2(15),age int, phoneno int, address varchar2 (20));
Insert into employee values(1,'vardhan','kumar',22,9812467899,'delhi');
Insert into employee values(2,'himani','sharma',32,9814126771,'mumbai');
Insert into employee values(3,'aayushi','shresth',24,9991261721,'kolkata');
Insert into employee values(4,'hemanth','sharma',25,9996172121,'banglore');
Insert into employee values(5,'sewathi','kapoor',26,9812161712,'hydrabad');



**create table2**
Create table projects (projectid int, employeeid int, clientid int, projectname varchar2 (4));
Insert into projects values (111,4,3,'p1');
Insert into projects values (222,2,1,'p2');
Insert into projects values (333,3,5,'p3');
Insert into projects values (444,3,2,'p4');


 
Inner join under equi join **

Select employee.employeeid, employee.fname, employee.lname, employee.age, employee.phoneno, employee.address, projects.projectid, projects.clientid, projects.projectname
From employee
Inner join projects on employee.employeeid=projects.employeeid;



Left join**
Select employee.employeeid, employee.fname, employee.lname, employee.age, employee.phoneno, employee.address, projects.projectid, projects.clientid, projects.projectname
From employee
Left join projects on employee.employeeid=projects.employeeid;



Right join**
Select employee.employeeid, employee.fname, employee.lname, employee.age, employee.phoneno, employee.address, projects.projectid, projects.clientid, projects.projectname
From employee
Right join projects on employee.employeeid=projects.employeeid;



Full join**
Select employee.employeeid, employee.fname, employee.lname, employee.age, employee.phoneno, employee.address, projects.projectid, projects.clientid, projects.projectname
From employee
Full join projects on employee.employeeid=projects.employeeid;



Comments

Popular Posts