Self join in Sql

Опубликовано: 14 Февраль 2026
на канале: Datasilicon
111
6

A self-join is a regular join that joins a table to itself. In practice, you typically use a self-join to query hierarchical data or to compare rows within the same table.

To form a self-join, you specify the same table twice with different table aliases and provide the join predicate after the ON keyword.

The following query uses an INNER JOIN that joins the table to itself:

SELECT select_list
FROM table_name t1
INNER JOIN table_name t2 ON join_predicate;