# id 칼럼에 기본키 설정
alter table aritcle add primary key(id);
# id 칼럼에 auto_increment를 건다.
alter table article modify column id int not null auto_increment;
# 조회수 가장 많은 게시물 3개 조회
select *
from article
order by hit
desc limit 3;
# 작성자명이 '홍길'로 시작하는 게시물만 조회
select *
from article
where nickname like '홍길%';
# 조회수가 10이상 55이하인 것만 조회
select *
from article where hit>=10 and hit <=55;
# 작성자가 '무명'이 아니고 조회수가 50이하인 것만 조회
select *
from article where nickname!='무명' and hit<=50;
# 작성자가 '무명'이거나 조회수가 55이상인 게시물 조회
select *
from article where nickname='무명' or hit>=55;
💡 새로 알게된 것
auto_increment
를 사용할 때는 해당 칼럼이primary key
여야 한다.