반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- c++
- axios
- css
- bit
- priority_queue
- routes
- JSX
- BinaryTree
- Navigation
- MySQL
- Props
- Context
- map
- React
- route
- Callback
- array
- queue
- state
- count
- 비트연산
- DP
- nodeJS
- event
- server
- node.js
- UE5
- treenode
- leetcode
- component
Archives
- Today
- Total
우사미 코딩
[MySQL] LEFT JOIN 본문
반응형
이거슨 leet code의 1378 문제
- SQL Schema
Create table If Not Exists Employees (id int, name varchar(20))
Create table If Not Exists EmployeeUNI (id int, unique_id int)
Truncate table Employees
insert into Employees (id, name) values ('1', 'Alice')
insert into Employees (id, name) values ('7', 'Bob')
insert into Employees (id, name) values ('11', 'Meir')
insert into Employees (id, name) values ('90', 'Winston')
insert into Employees (id, name) values ('3', 'Jonathan')
Truncate table EmployeeUNI
insert into EmployeeUNI (id, unique_id) values ('3', '1')
insert into EmployeeUNI (id, unique_id) values ('11', '2')
insert into EmployeeUNI (id, unique_id) values ('90', '3')
join 하고 unique_id, name을 출력한다.
만약 unique_id가 없다면 null로 표기한다.
- solution
SELECT unique_id, name
FROM Employees as emp
LEFT JOIN EmployeeUNI as uni
ON uni.id = emp.id
반응형
'MySQL' 카테고리의 다른 글
[MySQL] 문자열 일치 조건 SUBSTRING (0) | 2024.01.04 |
---|---|
[MySQL] 중복값 계산 (COUNT, DISTINCT) (0) | 2024.01.03 |
[MySQL] 홀수, 짝수 조건 설정하기 (ft. Mod연산) (0) | 2024.01.03 |
[MySQL] A에는 있지만 B에는 없는 데이터 + COUNT (0) | 2023.09.19 |
Comments