SQL

MySQL SELF JOIN

A SELF JOIN is a join that is used to join a table with itself. However, there is a need to combine data with other data in the same table itself. In that case, we use Self Join.

Syntax

SELECT s1.col_name, s2.col_name...  
FROM table1 s1, table1 s2  
WHERE s1.common_col_name = s2.common_col_name;

Example

 
SELECT  s1.rollno,s2.status
FROM fees s1, fees s2  
WHERE s1.status = s2.status;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *