SQL 20221123

신래은·2022년 12월 21일
0

SQL

목록 보기
3/6

DAY 27

DATE 문

• DATE_ADD( [기준날짜] , INTERVAL [더해질 날짜] )

select 
	*,
	tt_price * (1-tt_discount) as discounted,
	tt_price * (1-tt_discount) * tt_point as point,
	DATE_ADD(now(), INTERVAL tt_book_term DAY) as delivery_date
from test_table a join test_book b 
on a.tt_book_seq = b.book_seq;

• Select문 에는 계산식이 들어가도 됨.

select *, tt_price * (1 - tt_discount) as discounted,
tt_price * (1 - tt_discount) * tt_point as point 
from test_table;

• Table Data delete

delete from post_info ; -- 데이터 삭제
truncate post_info; -- 초기화

• DATE - 기간 사이의 값 조회하기

select *, DATE_ADD(bb_start_time, interval 3 day)  as end  
-- bb_start_time으로부터 3일 추가
from book_badges where bb_bi_seq = 1 
and 
	date_format(curdate(), '%Y-%m-%d') -- 이것이
between
	date_format(bb_start_time, '%Y-%m-%d') -- 이것과
and
	DATE_ADD(bb_start_time, interval 3 day); -- 이것 사이인가?

0개의 댓글