Everyday Dev System

엑셀보다 쉬운 SQL - 1일차 본문

내배캠 초기 학습/엑셀보다 쉬운, SQL

엑셀보다 쉬운 SQL - 1일차

chaeyoung- 2023. 5. 2. 18:01

여러 사람들이 같이 사용할 목적으로 데이터를 담는 통이라고 생각하면 된다.

데이터를 잘 꺼내오기 위해서 DB를 사용.

 

Create : Data 생성

Read : 저장된 Data 읽기

Update : 저장된 Data 변경

Delete : 저장된 Data를 삭제

 

*신입은 DB read만 잘해도 됨.

 

DBeaber 에서 Ctrl + Enter 쿼리문 실행

 

중복제거 및 count

select distinct(payment_method) from orders

select count(DISTINCT(name)) from users

limit

 

 

 

select * from orders

select order_no from orders

 

select * from orders

where payment_method = 'kakaopay'

 

select * from point_users

where point >=5000

 

 

// 퀴즈1

select * from point_users

where point >=20000

 

//퀴즈2

select * from users

where name LIKE '황%'

 

select * from users

where name = '황**'

 

//퀴즈3

select * from orders

where course_title ='앱개발 종합반' and payment_method = 'CARD'

 

 

select * from checkins

where week in (1,3)

 

select * from users u

where email like '%daum.net'

 

//퀴즈1

select * from orders o

where payment_method != 'CARD'

 

//퀴즈2

select * from point_users pu

where point BETWEEN 20000 and 30000

 

//퀴즈3

select * from users u

where email like 's%com'

 

//퀴즈4

select * from users u

where email like 's%com' and name like '이%'

limit 3

 

select distinct(payment_method) from orders

 

select count(DISTINCT(name)) from users

 

 

//퀴즈1

select * from users u

where name like '남%'

 

//퀴즈2

select * from users

where email like '%gmail%' and created_at BETWEEN '2020-07-12' and '2020-07-14'

 

//숙제

select * from orders

where email like '%naver.com' and course_title ='웹개발 종합반' and payment_method ='kakaopay'