SELECT column_name
FROM table_name1
WHERE VALUE IN
(SELECT column_name
FROM table_name2
WHERE condition)
SELECT *
FROM Customers
WHERE age = (
SELECT MIN(age)
FROM Customers
);
SUBQUERY IS NESTED QUERY INSIDE A SELECT,
INSERT OR UPDATE METHODS. OR INSIDE ANOTHER SUBQUERY
SELECT name, listed_price
FROM paintings
WHERE listed_price > (
SELECT AVG(listed_price)
FROM paintings
);
UPDATE dataflair_emp1
SET salary=35000
WHERE emp_id = ( SELECT emp_id
FROM dataflair_emp1
WHERE post='Sr.Manager');
select * from dataflair_emp1;
UPDATE Book SET note= 'editore: ' + (SELECT name FROM Publisher WHERE Publisher.ID = Book.publisher)
DELETE FROM dataflair_emp1
WHERE emp_id IN ( SELECT emp_id
FROM dataflair_emp2
WHERE age=25);
select * from dataflair_emp1;
We use subquery in order to get aggregate value in column without grouping data