[TIL] MySQL JOIN Cheat Sheet

3994 단어 JOINmysqlsqldbJOIN

📚TL;DR

  1. Join : 두개 이상의 테이블을 결합하여 나타낼 때 사용
  2. Full Outer Join : MySQL은 left join, right join, union으로 처리

1. employee

2. department

3. Inner Join

SELECT field1, field2
FROM table1
JOIN table2 ON condition

4. Left Outer Join

SELECT field1, field2
FROM table1
LEFT OUTER JOIN table2 ON condition

5. Right Outer Join

SELECT field1, field2
FROM table1
RIGHT OUTER JOIN table2 ON condition

6. Full Outer Join

SELECT field1, field2
FROM table1
LEFT OUTER JOIN table2 ON condition

UNION

SELECT field1, field2
FROM table1
RIGHT OUTER JOIN table2 ON condition

7. Cross Join

SELECT field1, field2
FROM table1
CROSS JOIN table2

번외 권한 추가

mysql> CREATE USER 'name'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON datbase.table TO 'name'@'%';

좋은 웹페이지 즐겨찾기