SELF JOIN is a regular join used to join the table with itself.
Syntax of SELF JOIN in SQL-
SELECT <column_name(s)>
FROM <table1> t1, <table1>t2
WHERE<condition>;
Example of SELF JOIN in SQL-
SELECT A.CustomerName AS Customer1, B.CustomerName AS Customer2, A.City
FROM Customers A, Customers B
WHERE A.CustomerID <> B.CustomerID
AND A.City = B. City;
โ SELF JOIN query customers that are from the same city.
Leave a Reply