Question : http://www.gurubee.net/article/50384
More questions & Answer: http://www.gurubee.net/article/45391
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | SELECT COUNT(*) FROM TABLE_NAME WHERE 조건1 AND ( ( ST_DT >= DATE_FORMAT(#{stDt},'%Y%m%d') AND ST_DT <![CDATA[<=]]> DATE_FORMAT(#{endDt},'%Y%m%d') ) OR ( END_DT >=DATE_FORMAT(#{stDt},'%Y%m%d') AND END_DT <![CDATA[<=]]>DATE_FORMAT(#{endDt},'%Y%m%d') ) OR ( ST_DT <![CDATA[<=]]> DATE_FORMAT(#{stDt},'%Y%m%d') AND END_DT >=DATE_FORMAT(#{endDt},'%Y%m%d') ) OR ( ST_DT >= DATE_FORMAT(#{stDt},'%Y%m%d') AND END_DT <![CDATA[<=]]> DATE_FORMAT(#{endDt},'%Y%m%d') ) ) | cs |
반응형
'Database' 카테고리의 다른 글
MySQL JOIN vs UNION (0) | 2017.02.15 |
---|---|
MYSQL 날짜 형식 (0) | 2017.02.13 |
mybatis selectkey (0) | 2017.02.02 |
SQL JOIN (0) | 2017.01.06 |
SQL CHAR와 VARCHAR의 차이 (0) | 2017.01.04 |