HomePagev2 Forums SQL Discussions What are self joins and why are they useful? Reply To: What are self joins and why are they useful?

  • Karri Bindu Madhavi

    Member
    September 11, 2020 at 3:34 am

    <p style=”text-align: left;”>A self join is the one which can be used to join a table itself without depending on any other.</p>
    It is useful to compare rows or query the data within the table.

    A self join also use inner join(return rows when there is a match in both rows) and left join(return all rows from the left table even if there are no matches in the right table).

    Self join syntax:

    “SELECT column_name(s)

    FROM table1 T1, table1 T2

    WHERE <b>condition;”</b>

    T1,T2 are the different table aliases for the same table.