
# 사용자에게 특정 데이터베이스 모든 권한 부여
GRANT ALL ON dbname.* to 'username'@'localhost';
# 사용자에게 특정 데이터베이스 모든 권한 삭제
REVOKE ALL ON dbname.* from 'username'@'localhost';
여러 개의 SQL문을 합쳐서 하나의 SQL문으로 만들어주는 방법
(합치는 SQL문의 컬럼 개수 같아야 함)
select * from test1
union (all)
select * from test2;
두 개 이상의 데이블을 결합하는 방법

# inner join
select column1, column2 from tableA
inner join tableB
on tableA.column = tableB.column
where condition;
# left join
select column1, column2 from tableA
left join tableB
on tableA.column = tableB.column
where condition;
# right join
select column1, column2 from tableA
right join tableB
on tableA.column = tableB.column
where condition;
# full outer join
select column1, column2 from tableA
full outer join tableB
on tableA.column = tableB.column
where condition;
# self join
select column1, column2 from tableA, tableB
where condition;
조건에 집계함수가 포함되는 경우 where절 대신 having 사용
select column1, column2, ... from table
where condition
group by column1, column2
having condition (Aggregate Functions)
order by column1
# Scalar Sub Query (select절에 사용)
select column1, (select column2 from table2 where condition)
from table1
where condition;
# Inline View (from절에 사용)
select a.column, b.column
from table1 a, (select column1, column2, from table2) b
where condition;
# Nested Sub Query (where절에 사용)
# # Single Row : 하나의 열을 검색하는 서브쿼리
# # Multiple Row : 하나 이상의 열을 검색하는 서브쿼리
# # Multiple Column = 하나 이상의 행을 검색하는 서브쿼리