A24 Exp03 DBMS
A24 Exp03 DBMS
Mumbai University
Vidyavardhini’s College of Engineering and Technology, Vasai
Experiment No: - 3
Theory: -
2. Retrieving record with Non-Equijoins: contain something other than equality operator. e.g.:
SELECT e.last_name, e.salary, j.grade_level
FROM employees e, job_grades j
WHERE e.salary
BETWEEN j.lowest_sal AND j.highest_sal;
3. Outer join: the missing rows can be returned if an outer join operator is used in join condition.
5. Natural Joins: select record from tables that have equal values in all matched columns. e .g.:
SELECT department_id, department_name’ location-id, city
FROM departments
NATURAL JOIN locations;
Conclusion:
You should have learned how to use joins to display data from multiple tables
1. Write a query to display the last_name and department_name of all the employees 2. Write a
3. Write a query to display the last name, department name, location_ID, and city of all employees
who earn a commission
4. Create a unique listing of all job_id’s that are in department 80. Include the City of the
department in the output.
5. Write a query to perfom a LEFT OUTER Join on the tables EMPLOYEES and
DEPARTMENTS
6. Write a query to perform a RIGHT OUTER Join on the tables EMPLOYEES and
DEPARTMENTS
7. Write a query to perform a FULL OUTER Join on the tables EMPLOYEES and
DEPARTMENTS
Code:
CREATE TABLE employ(
employee_id INTEGER,
last_name VARCHAR2(50),
job_id VARCHAR2(50),
department_id integer,
salary INTEGER,
commision INTEGER,
department_name varchar2(50),
location_id varchar2(50),
city varchar2(50)
);
SELECT *
FROM employ
CROSS JOIN DEPARTMENTS;
SELECT last_name,
department_name,
location_id,
city
FROM employ
WHERE commision IS NOT NULL;
SELECT employ.employee_id,
employ.last_name,
employ.job_id,
employ.department_id,
employ.salary,
DEPARTMENTS.department_name,
DEPARTMENTS.location
FROM employ
LEFT OUTER JOIN DEPARTMENTS
ON employ.department_id = DEPARTMENTS.department_id;
Output: