PHPSCHOOL 톡박에 좋은 글이 올라와 포스팅 해봅니다.
많은 개발자 분들이 놓치기 쉬운 부분이네요.(OR OR OR OR 남발)
-- 교차선분조건 (A) = (1), (B) = (10)
WITH tmp AS
(
SELECT 0 IDX, 11 A, 12 B FROM DUAL UNION ALL
SELECT 1, -2, 3 FROM DUAL UNION ALL
SELECT 2, 2, 5 FROM DUAL UNION ALL
SELECT 3, 7, 11 FROM DUAL UNION ALL
SELECT 4, -1, 11 FROM DUAL UNION ALL
SELECT 5, -3, -1 FROM DUAL
)
SELECT * FROM tmp WHERE (1) < B AND (10) > A