코딩 교육 TIL

2024-01-24 AI 코딩 TIL

HyunjunPark 2024. 2. 16. 20:22

http이란?

http or https: 프로토콜(자료를 요청하고 받는 형식)


SQL 이란?

데이터 서버에 데이터 가져오기

select : 쿼리 가져온다

* : 전부

from : 테이블 특정 지점 선택

where = 내가 검색하고 싶은 값만 따로 필터링하는 것

select → from → where 순으로 적어줘야 한다.

비교문을 사용 가능하다

= : 같다

< : 크다

<= : 크거나 같다

> : 작다

>= : 작거나 같다

<> : 같지 않다


비교 조건문

between 사용법

where "쿼리" between "a" and "b"


IN : 특정 조건만 필터링

WHERE age IN (21, 25, 27)


like : 비슷한 조건 검색 필터

WHERE name LIKE '김%'

여기서 이름 뒤에 %를 붙이면 앞글자 가 포함된 모든 글자라는

'%김%' 중간에 들어간 글자

'%김' 마지막 글자


where 조건에 합치거나 따로 조건을 줄 때

값을 더한 다음 이름을 정해주고 표기하는 방법

select food_preparation_time, delivery_time, food_preparation_time + delivery_time as total_time from food_orders

값을 평균 및 총합

select sum(food_preparation_time) total_food_preparation_time, avg(delivery_time) avg_food_preparation_time from food_orders

개수 구하기

select count(1) count_of_orders, count(distinct customer_id) count_of_customers from food_orders

count(1) : 1의 의미는 모든 경우를 포함

count( distinct customer_id) : distinct는customer_id 의 조건중 몇 개의 다른 종류가 있는지

최솟값 최댓값

select min(price) min_price, max(price) max_price from food_orders

group by, order by 에 대해서

group by : 그룹별로 같은 것 끼리 모아줄 수 있다.

order by : 순차 정렬로 기본 내림차순으로 정렬을 한다.

만약에 역순으로 오름차순정렬을 하고 싶다면 desc 을 뒤에 추가적으로 적어주면 가능하다.