What is the purpose of a self-join in SQL?

  • To combine rows from the same table based on a related column
  • To eliminate duplicate rows from a result set
  • To join two different tables based on a common column
  • To perform complex calculations within a query
A self-join in SQL is used when you want to combine rows from the same table based on a related column. It is commonly used to retrieve hierarchical data or to compare rows within the same table. For example, when you have an employee table where each row contains an employee and their manager, you can use a self-join to retrieve the manager's details for each employee.
Add your answer
Loading...

Leave a comment

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