Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Database Administration

by
Muhammad Haleem
Overview
Data Entry
Displaying Data From multiple tables
Types of join
Inner join
Left outer join
Right outer join
Full outer join
Like Operator
Displaying Data from multiple tables
When we are working with relational database, most often, we
are retrieving the data from multiple tables. In this case we need
to use join.
The purpose of a join is to combine the data from two or more
tables.
A join is actually performed whenever multiple tables appear in
the FROM or where clause that point to those tables.
Table to use in our examples
Emp

Dept
Inner Join
• The join of two tables returning only matched rows is called
an inner join.

Query:
SELECT E.*, DNAME FROM EMP E INNER JOIN
DEPT D ON E.DEPTNO=D.DEPTNO;
Inner Join…
Left Outer Join

• A join between two tables that returns the results of the


inner join as well as the unmatched rows from the left table is
called a left outer join.

Query:
SELECT E.*, DNAME FROM EMP E LEFT OUTER
JOIN DEPT D ON E.DEPTNO=D.DEPTNO;
Left Outer Join…
Right Outer Join

• A join between two tables that returns the results of the


inner join as well as the unmatched rows from the right table
is called a right outer join.

Query:
SELECT E.*, DNAME FROM EMP E RIGHT OUTER
JOIN DEPT D ON E.DEPTNO=D.DEPTNO;
Right Outer Join…
Full outer join
• A join between two tables that returns the results of an inner
join as well as the results of a left and right join is a full outer
join.

Query:

SELECT E.*, DNAME FROM EMP E FULL OUTER


JOIN DEPT D ON E.DEPTNO=D.DEPTNO;
Full outer join (Example)
LIKE Operator
• Use the LIKE operator to perform wildcard searches of
valid search string values.
• Search conditions can contain either literal characters or
numbers:
• % denotes zero or many characters.SELECT first_name
FROM employees
• _ denotes one character. WHERE first_name LIKE 'S%' ;
Combining Wildcard Characters
• You can combine the two wildcard characters (%, _) with literal
characters for pattern matching:
SELECT last_name
FROM employees
WHERE last_name LIKE '_o%' ;
Thank You

You might also like