두 테이블의 공통된 부분만 가져올 때 사용
아래는 해시태그가 UMC인 책의 이름을 가져오는 쿼리문
select b.*
from book as b
inner join book_hash_tag as bht on b.id = bht.book_id
inner join hash_tag as ht on bht.hash_tag_id = ht.id
where ht.name = "UMC";
교집합 외부에 존재하는 데이터를 가져올 때 사용
Left 조인이 일반적으로 가장 많이 사용됨
아래는 left join을 그림으로 표현한 이미지.

이처럼 모든 좌측 테이블을 가져오되, 조인 불가능한 것은 NULL로 채운다.
아래는 offset을 이용해 최신순 정렬을 구현한 쿼리문
select * from book
order by created_at desc
limit 15 offset 0;
limit: 가져올 데이터의 양offset: 가져올 데이터의 초기 위치 값limit 15 offset 0 은 0에서부터 15개의 데이터를 가져오라는 뜻이다.cursor: 마지막으로 조회한 컨텐츠를 의미
아래는 cursor를 이용해 최신순 정렬을 구현한 쿼리문
Ex) 마지막으로 본 book_id가 3일 때 , 해당 아이디의 책이 생성된 날짜 이전(created_at < )의 책들을 내림차순으로 정렬하여 최근에 생성된 책부터 15권을 출력하라
select * from book
where created_at < (select created_at from book where id = 3)
order by created_at desc;
select * from user_mission um
where status = "progress" or status = "complete"
limit ? offset (?-1)*?;
insert into review (user_id, restaurant_id, rating, body, created_at, updated_at)
values(?, ?, ?, ?, now(), now());
select *
from mission as m
join user_mission as um on m.id = um.mission_id
join restaurant on um.restaurant_id = restaurant .id
join region on region.id = restaurant.region_id
where region.name = ?
limit ? offset(?-1)*?;
select * from user;