2022년 10월 10일 스파르타 코딩클럽 SQL 공부 1주차
이미 컴퓨터에 MySQL를 설치해두었는데, 스파르타 강의에서는 dbeaver 라는 프로그램을 사용해서 수업을 진행해서 새로 설치했다. 수업에 사용할 db도 스파르타에서 제공해줘서 쉽게 따라할 수 있었다. DBeaver 은 MySQL, PostSQL, 0racle 등 다양한 데이터베이스를 모두 지원하며, 인터페이스가 사용하기 편하게 되어 있는 오픈소스 프로그램이다.
+)MySQL 설치에 참고한 블로그들
1) https://ansan-survivor.tistory.com/1130
2) https://hongong.hanbit.co.kr/mysql-%EB%8B%A4%EC%9A%B4%EB%A1%9C%EB%93%9C-%EB%B0%8F-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0mysql-community-8-0/
VisualStudio 를 최신 2022년 버전으로 설치했더니.. MySQL for Visual Studio는 visual studio 2017이나 2019가 설치되어 있어야 한다는 메시지가 나와서 다시 설치했음..
같지 않음 조건
ex. 웹개발 종합반이 아닌
select * from orders
where course_title != "웹개발 종합반";
범위 조건
ex. 7월 13일~15일
select * from orders
where created_at between "2020-07-13" and "2020-07-15";
포함 조건
ex. 1주차와 3주차 다짐들
select * from checkins
where week in (1, 3);
패턴(문자열 규칙)
ex. daum.net 인 이메일 주소들 (daum.net 앞에 무엇이 있든지 %)
select * from users
where email like '%daum.net';
ex. 이메일이 a로 시작해서 뭐가 있든지 t로 끝나는 것
select * from users
where email like 'a%t'
ex. 5개까지만 보여줘
select * from orders
where payment_method = 'kakaopay'
limit 5
중복제거하고 보기
ex. 지불방식에 뭐가 있지? 뭐가 있는지 보려고 할 때
select distinct(payment_method) from orders
몇개일까 세는 것
ex. 카카오페이를 사용한 주문은 몇 건일까?
select count(*) from orders
where payment_method = 'kakaopay'
ex. 우리 회원들은 몇 종류의 성씨를 가졌을까?
select count(distinct(name)) from users