de_notes

📚 SUBQUERY IN CONDITION

A subquery in a condition is used to compare a value from the main query to the result of a subquery.
It allows dynamic filtering based on the results of another query.


🛠️ Basic Syntax

SELECT column1, column2
FROM table_name
WHERE column_name operator (SELECT column_name FROM another_table WHERE condition);

Example

SELECT first_name, last_name
FROM employees
WHERE department_id IN (SELECT department_id FROM departments WHERE location = 'New York');

Key Points

Additional Example

SELECT product_name
FROM products
WHERE price > (SELECT AVG(price) FROM products);

🎥 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: COALESCE Next ➡️ WINDOW FUNCTION