Equi and Non-Equi Join in SQL

In this tutorial, We will learn the concept of Equi and Non-Equi Join in SQL.

 

Equi and Non-Equi Join in SQL

EQUI Join in SQL

It is a simple SQL join condition which uses the equal sign as the comparison operator. Two types of equi joins are SQL Outer join and SQL Inner join.

 

SQL EQUI JOIN performs a JOIN against equality or matching column(s) values of the associated tables. An equal sign (=) is used as comparison operator in the where clause to refer equality.

SQL Syntax :

SELECT column1, Column2

FROM table1, table2

WHERE table1.column_name = table2.column_name;

 

Non-Equi Join in SQL

It is SQL join condition which makes use of some comparison operator other than the equal sign like >, <, >=, <= .

SQL Syntax :

SELECT column1, Column2

FROM table1, table2

WHERE table_name1.column [> | < | >= | <= ] table_name2.column;

 

SQL> Select * from Table1, Table2 

         where Table1.Id BETWEEN 10 and 20.

 

The above query will return the records from table1 whose ID is between 10 and 20 and all records from table2. That’s all.

 

I hope you will enjoy the tips while playing with SQL Server. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

0 Comment

Leave a Reply