-
MySQL/예약기간 중복 찾기DBMS/MySql (MariaDB) 2022. 11. 7. 10:37
1-20분만 보면 될거라 생각해지만.. 장정 1시간 넘게 애먹인 놈... 젝1
중복되는 기간 찾기
WITH T_CONTRACT AS ( SELECT 1, '20221106' AS START_DATE, '20221107' AS END_DATE, 'NO' AS OK UNION ALL SELECT 1, '20221108' AS START_DATE, '20221109' AS END_DATE, 'NO' AS OK UNION ALL SELECT 1, '20221110' AS START_DATE, '20221111' AS END_DATE, 'NO' AS OK UNION ALL SELECT 1, '20221113' AS START_DATE, '20221114' AS END_DATE, 'OK' AS OK ) SELECT T_CONTRACT.* FROM T_CONTRACT, (SELECT @IN_START_DT := '20221111', @IN_END_DT := '20221113') AS A WHERE T_CONTRACT.START_DATE < @IN_END_DT AND T_CONTRACT.END_DATE > @IN_START_DT ;
'DBMS > MySql (MariaDB)' 카테고리의 다른 글
MariaDB에서 조회 결과 업데이트 하기 (0) 2023.03.09 MySQL/날짜 Recursive list (두 날짜 사이의 날짜 목록) (0) 2022.11.07 MySQL/정규식 검색 (0) 2022.09.19 MySQL/Character Set & Collation 및 Emoji (utf8 vs utf8mb4) (0) 2021.04.21 MySQL/한글, 영문, 숫자, 특문 정렬방식 (2) 2021.03.17