SQL SELF JOIN

A SQL SELF JOIN is used to JOIN in which a table is joined with itself as if the table were two tables; temporarily renaming at least one table in the SQL statement. When the table has a FOREIGN KEY which references its own PRIMARY KEY.

SELF JOIN in SQL

  • To JOIN a table itself means each row of the table is combined with itself with every other row of the table.
  • The SELF JOIN can be viewed as a JOIN of two copies of the same table.
  • The table is not actually copied, but SQL performs the command as though it were.

SELF JOIN Syntax

SELECT column_name(s)
FROM table_name T1 JOIN table_name T2
WHERE condition;
  • T1 and T2 are different table Aliases for the same table.
  • A SQL SELF JOIN is a regular JOIN, It accurs when a table takes to joined with itself.

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)