알고리즘/프로그래머스문제풀이

SQL_group,having,join

개발자 덕구🐾 2022. 9. 21. 20:43
728x90

 

group by : 그룹화 

 

 

having : 그룹에  조건을 건다.

where : 레코드에 조건을 건다. 

 

 

hour(datetime) : 시간만 추출 

 

 


Join 

 

 

양쪽에 다 있는 것 : inner join 

양쪽 + 왼쪽 : left outer join

 

 

예시 ) 

select * from topic left join author on topic.author_id = author.author_id

topic 테이블을 왼쪽에 놓고 오른쪽에 author 테이블을 놓는데 이 둘은 author_id로 연결되는 것이다 .

만약 topic에는 있지만 author 테이블에 없다면 authro에 있는 data를 null로 처리한다. 

 

반응형