Joins using two tables..

Muhsinathk
Posted by Muhsinathk under Sql Server category on | Points: 40 | Views : 1394
CREATE TABLE department
(
DepartmentID INT,
DepartmentName VARCHAR(20)
);

CREATE TABLE employee
(
LastName VARCHAR(20),
DepartmentID INT
);]

INNER JOIN
SELECT * FROM employee INNER JOIN department ON employee.DepartmentID = department.DepartmentID;
or
SELECT * FROM employee, department WHERE employee.DepartmentID = department.DepartmentID;

CROSS JOIN
SELECT * FROM employee CROSS JOIN department;

EQUI JOIN
SELECT * FROM employee JOIN department ON employee.DepartmentID = department.DepartmentID;

LEFT OUTER JOIN
SELECT * FROM employee LEFT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

RIGHT OUTER JOIN
SELECT * FROM employee RIGHT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

Comments or Responses

Login to post response