Skip to main content

Posts

Showing posts from January, 2012

Sql Joins

Different SQL JOINs Before we continue with examples, we will list the types of JOIN you can use, and the differences between them.
·JOIN: Return rows when there is at least one match in both tables
·LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
·RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
·FULL JOIN: Return rows when there is a match in one of the tables

The INNER JOIN keyword return rows when there is at least one match in both tables.
SQL INNER JOIN Syntax
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
PS: INNER JOIN is the same as JOIN.


The INNER JOIN keyword return rows when there is at least one match in both tables. If there are rows in "Persons" that do not have matches in "Orders", those rows will NOT be listed.


The LEFT JOIN keyword returns all rows from the left table (table_name1), even i…