하나의 SQL문(Mainquery) 안에 포함되어있는 또 다른 SQL(Subquery)문
SELECT절에서 사용하는 서브쿼리
select column1, (select column2 from table2 where condition)
from table1
where condition;
FROM절에 사용하는 서브쿼리
select a.column, b.column
from table a, (select column1, column2 from table2) b
where condition;
WHERE절에서 사용하는 서브쿼리
select column_name
from table_name
where column_name = (select column_name
from table_name
where condition)
order by column_name;
select column_name
from table_name
where column_name in (select column_name
from table_name
where condition)
order by column_name;
select column_name
from table_name a
where (a.column1, a.column2, ...) in (select b.column1, b.column2, ... from table_name b
where a.column_name = b.column_name)
order by column_name;