1. resources 폴더에 application.properties 파일이 있다. - 이 파일에 아래와 같이 설정을 해준다. - 각 프로퍼티속성이 의미하는 것은 속성의 이름을 보면 알 수 있다. 2. Mapper 파일의 인터페이스 파일을 작성한다. - @Mapper 어노테이션을 붙여줘서 스프링이 mapper 컴포넌트로 관리할 수 있게 해준다. 3. application.properties 파일에 mapper 파일 위치를 설정해 줬다. - resources 폴더 아래 위치에, 설정해놓은 폴더를 만든다. - 그리고 mapper 파일을 생성. 4. mapper 파일에 mapper.dtd 선언을 해주고 SQL 문을 작성한다. 5. Service 파일에서 mapper interface를 @Autowired로 ..
select T_main.countryCode as `countryCode`, T_main.entity as `entity`, ifnull(T_main.saleType, 'Total') as `saleType`, case when T_main.saleType is null then 'Total' when T_main.productName is null then 'sub-Total' else `T_main`.`productName` end as `productName`, T_main.disCode as `disCode`, case when T_main.saleType is null then '-' when T_main.productName is null then '-' else `T_main`.`itemN..
컬럼과 로우를 위치 변경하는 pivot 쿼리 예시. SELECT CASE WHEN T_TEAM_SALES.salesUserId = 'L000000' THEN 'Others' WHEN T_TEAM_SALES.salesUserId = 'L999999' THEN 'Resigned' WHEN `sales_user`.`name` IS NULL THEN 'Others' ELSE `sales_user`.`name` END AS `salesUserName`, CASE WHEN T_TEAM_SALES.salesTeamId = 'T0000000000' THEN 'Others' WHEN `sales_team`.`name` IS NULL THEN 'Others' ELSE `sales_team`.`name` END AS `sa..
-- 첫번째 쿼리. SELECT o.invoice_code FROM ORDER o INNER JOIN ORDER_USER bot ON o.id = bot.order_id LEFT JOIN BILLING_BOT_MAP map ON bot.name = map.bot_name LEFT JOIN BILLING b ON map.biling_id = b.id WHERE o.order_code = 'code123'; -- 두번째 쿼리. SELECT b.invoice_code FROM ORDER o INNER JOIN ORDER_USER bot ON o.id = bot.order_id LEFT JOIN BILLING_BOT_MAP map ON bot.name = map.bot_name LEFT JOIN BILLING ..
- 전체값을 일반적인 insert 문으로 삽입한 경우. // 일반적인 insert 문의 경우. if (dto.getItemList() != null) { for (PromotionItemDTO item : dto.getItemList()) { DSL.insertInto(PROMOTION_REGISTER_ITEM) .set(PROMOTION_ITEM.REGISTER_ID, DSL.select(PROMOTION_REGISTER_ITEM.ID).from( PROMOTION_REGISTER_ITEM) .where(PROMOTION_REGISTER_ITEM.FILE_KEY.eq(dto.getFileKey())) .orderBy(PROMOTION_REGISTER_ITEM.ID.desc()).limit(1) .fet..
update시 관련 테이블의 데이터를 이용하려면 아래와 같이 조인 하여 사용한다. update account a inner join account_order o on a.id = o.user_id set a.order_expiry_at = o.order_end_at WHERE o.current_status = 'ORDERFAILED' AND o.updated_at >= '2020-10-21' AND o.error_msg = 'no value present';