
여러 개의 SQL문을 합쳐서 하나의 SQL문으로 만들어주는 방법(칼럼의 개수가 같아야함)
문법
- UNION : 중복된 값을 제거하여 알려준다.
- UNION ALL : 중복된 값도 포함하여 모두 보여준다.
select column from table UNION select column from table1


두 개의 테이블에서 공통된 요소들을 통해 결합하는 방식(교집합)
select column from table1 INNER JOIN table2 ON table1 column = table2 column where 조건;

두 개의 테이블에서 공통영역을 포함해 왼쪽 테이블의 다른 데이터를 포함하는 방식
select column from table1 LEFT JOIN table2 ON table1.column = table2.column where 조건

두 개의 테이블에서 공통영역을 포함해 오른쪽 테이블의 다른 데이터를 포함하는 방식
select column from table1 RIGHT JOIN table2 ON table1.column = table2.column where 조건

두 개의 테이블에서 공통영역을 포함해 양쪽 테이블의 다른 영역을 모두 포함하는 방식(합집합)
select column from table1 FULL OUTER JOIN table2 ON table1.column = table2.column where 조건MySQL에서는 FULL JOIN을 지원하지 않는다.
select column from table1 LEFT JOIN table2 ON table1.column = table2.column where 조건 UNION select column from table1 RIGHT JOIN table2 ON table1.column = table2.column where 조건

select column from table1, table2 where 조건


여러 문자열을 하나로 합치거나 연결
select concat(str1,str2,....)


칼럼이나 테이블에 이름 별칭 생성
#ALIAS 문법 - Column SELECT column as alias FROM tabelname #ALIAS 문법 - Table SELECT * FROM tablename as alias;


검색한 결과의 중복 제거
SELECT DISTINCT column1, column2 FROM tablename;


검색 결과를 정렬된 순으로 주어진 숫자만큼 조회
select column from table where condition limit number;

