de_notes

📚 SELF JOIN

A SELF JOIN is a SQL operation where a table is joined with itself.
It is useful for comparing rows within the same table.


🛠️ Basic Syntax

SELECT A.column1, B.column2
FROM table_name A
JOIN table_name B
ON A.common_column = B.common_column;

Example

SELECT A.employee_id, A.first_name, B.manager_id, B.first_name AS manager_name
FROM employees A
JOIN employees B
ON A.manager_id = B.employee_id;

Key Points

Additional Example

SELECT A.customer_name AS referrer, B.customer_name AS referred
FROM customers A
JOIN customers B
ON A.customer_id = B.referrer_id;

🎥 Video Notes


📝 Problem Description

Describe the problem, challenge, or topic discussed in a video related to SELECT FROM.
What concept was explained or what exercise was solved?


DataBase Given


💻 My SQL Code

-- Write your SQL code attempt or solution related to SQL COMMAND
SQL COMMAND

🧠 Solution Code / Explanation

SQL COMMAND

Explanation - Explain what you learned, any key takeaways, or how you solved the problem related to COMMAND._


⬅️ Previous: JOIN WITH MULTIPLE KEYS Next ➡️ UNION