SQL 20221229

신래은·2022년 12월 21일
0

SQL

목록 보기
4/6

DAY 31

create view product_all_info_view as
-- 상품 상세 조회 SQL
select a.*, b.cate_name, c.*, d.si_name, e.manu_name 
from product_basic_info a 
inner join category_info b on a.pbi_cate_seq = b.cate_seq
inner join product_detail_info c on a.pbi_pdi_seq = c.pdi_seq
inner join store_info d on a.pbi_si_seq = d.si_seq
inner join manufacturer_info e on a.pbi_manu_seq = e.manu_seq;

-- 상품번호와 일치하는 상품의 정보 1줄만 출력
select * from product_all_info_view where pbi_seq = 5;

select cate_seq from category_info where cate_parent_seq = 1;

-- 최상위 카테고리 번호로 제품 정보 조회 (상위 카테고리 메뉴 클릭 시)
select * from product_basic_info where pbi_cate_seq in -- (2,7);
select cate_seq from category_info where cate_parent_seq = 1;
-- 하위 카테고리 번호로 제품정보 조회 (하위 카테고리 메뉴 클릭 시)
select * from product_basic_info where pbi_cate_seq = 2;
-- 제품 목록 요약
create view product_summary_view as
select 
	pbi_seq, pbi_name, pbi_sub, pbi_price, pbi_discount_rate,
	pbi_delivery,
	pbi_price * (1 - pbi_discount_rate) as discounted,
	pbi_discount_rate * 100 as discount_percent,
	pbi_cate_seq, b.manu_name
from product_basic_info a inner join manufacturer_info b
on a.pbi_manu_seq = b.manu_seq;
-- 요약 뷰에서 카테고리 번호로 제품정보 조회
-- 최상위 카테고리 번호로 제품 정보 조회 (상위 카테고리 메뉴 클릭 시)
select * from product_summary_view where pbi_cate_seq in -- (2,7);
(select cate_seq from category_info where cate_parent_seq = 1);
-- 하위 카테고리 번호로 제품정보 조회 (하위 카테고리 메뉴 클릭 시)
select * from product_summary_view where pbi_cate_seq = 4;
-- 검색 키워드를 통한 제품정보 조회
-- 단일 키워드 -- 제품명으로 검색
select * from product_summary_view where pbi_name like '%목초%';
-- 단일 키워드 -- 제조사명으로 검색
select * from product_summary_view where manu_name like '%일상%';

vscode program 설치 시

gradle extension pack
extension pack for java
getter and setter generator
korean language pack
material icon theme
lombok annotations ~
spring boot extension pack
git graph
beautify
확장 설치

0개의 댓글