강의를 듣다 끊겨서 다시 들어와 예제를 풀어보려니,
사용했던 명령어가 기억이 나질 않아 정리해두면 참고할 때 좋을 것 같다.
⦁ 전체 테이블 보기
show tables;
⦁ orders 해당 테이블 데이터 가져오기
select * from orders;
⦁ orders 테이블의 특정 필드만 가져오기
select created_at, course_title, payment_method, email from orders;
⦁ 포인트가 20000점 보다 많은 유저
select * from point_users
where point > 20000;
⦁ 성이 황씨인 유저
select * from users
where name = "황**";
⦁ 웹개발 종합반이면서 결제수단이 CARD인 주문
select * from orders
where course_title = "웹개발 종합반" and payment_method = "CARD";
⦁ '같지 않음' 조건
!=
⦁ 7월 13일 ~ 7월 14일의 주문데이터
select * from orders
where created_at between "2020-07-13" and "2020-07-15";
⦁ 다음 (daum) 이메일을 사용하는 유저
select * from users
where email like '%daum.net';
⦁ 일부 데이터 5개만 가져오기
select * from orders
where payment_method = "kakaopay"
limit 5;
⦁ 중복 데이터 제외하고 가져오기
select distinct(payment_method) from orders;
⦁ 몇 개인지 숫자 세기
select count(*) from orders
⦁ Distinct와 Count를 같이 사용하기
SELECT count(distinct(name)) from users;