Home >

SQL How To - Syntax of INNER JOIN, EQUIJOIN and NATURAL JOIN

8. March 2011

 

An INNER  JOIN combines the records from two tables using comparison operators in a condition. Columns are returned only where the joined rows match the condition.

Here the quick review of the syntax of the INNER JOIN:

SELECT somecolumns
FROM table1
INNER  JOIN
table2
ON somecondition

If the condition (somecondition in above syntax) tests the equality then INNER JOIN becomes EQUIJOIN. EQUIJOIN tests for equality.

Similarly, if the same condition testes in-equality using <> symbol, then INNER JOIN becomes NON-EQUIJOIN.

Last but not the least, is the NATURAL JOIN. Natural Joins only work if the columns you are joining by has the same name in both tables. So NATURAL JOIN, bascially identifies joining column names automatically and you don't have to specify condition.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading