SQLite Outer Join

In SQL standard, there are three types of outer joins:

  • Left outer join
  • Right outer join
  • Full outer join.

But, SQLite supports only Left Outer Join.

SQlite Left Outer Join

The SQLite left outer join is used to fetch all rows from the left hand table specified in the ON condition and only those rows from the right table where the join condition is satisfied.

Syntax:

snippet
SELECT ... FROM table1 LEFT OUTER JOIN table2 ON conditional_expression

Or

snippet
SELECT ... FROM table1 LEFT OUTER JOIN table2 USING ( column1 ,......

Image representation:

Sqlite Outer join 1

We have two tables "STUDENT" and "DEPARTMENT".

Sqlite Outer join 2

The "STUDENT" table is having the following data:

Sqlite Outer join 3

The "DEPARTMENT" table is having the following data:

Sqlite Outer join 4

Let's take the above two tables "STUDENT" and "DEPARTMENT" and make an inner join according to the below conditions:

Example:

snippet
SELECT EMP_ID, NAME, DEPT FROM STUDENT LEFT OUTER JOIN DEPARTMENT
ON STUDENT.ID = DEPARTMENT.EMP_ID;
Sqlite Outer join 5
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +