본문 바로가기

개발/sql

(3)
프로그래머스_우유와 요거트가 담긴 장바구니 inner join 사용 inner join 은 합집합이다 내가 쓴 코드 -- 코드를 입력하세요 select orgin.cart_id from CART_PRODUCTS orgin inner join (select * from CART_PRODUCTS where name ='Yogurt') Yogurt on orgin.id=Yogurt.id inner join (select * from CART_PRODUCTS where name ='Milk') Milk on Yogurt.cart_id= Milk.cart_id order by orgin.cart_id 음....좀 무식해보인다. 집에가서 다시 해봐야지
프로그래머스_헤비유저가 소유한 장소 HAVING절 사용(left outer join) 1. 헤비유저를 찾는 구절 select host_id from places group by host_id having count(host_id)>1 2. join을 사용해 결과출력 select a.id, a.name, a.host_id from places a right outer join (select host_id from places group by host_id having count(host_id)>1) b on a.host_id=b.host_id 3. 결과
개인정보 보호 처리 sql 1. 개인정보 처리를 안해서 급하게 구글보고 찾아서 한 첫번째 쿼리 INSERT 테이블명 ( 고유아이디, 고객명, 휴대전화 앞자리, 휴대전화 중간자리, 휴대전화 뒷자리, 메일, 기본주소, 상세주소) VALUES( ${고유아이디}, substr(${고객명},1,1)||lpad('*',length(${고객명})-2,'*')||substr(${고객명}, length(${고객명}),1),--고객명 ${휴대전화 앞자리}, '****', ${휴대전화 뒷자리}, substr(${메일},1,1)||lpad('*', REGEXP_INSTR(${메일}, '@')-2,'*')||substr(${메일}, REGEXP_INSTR(${메일}, '@'),20), --메일 ${기본주소}, '******' ) 고객명은 처음과 끝자리를..