일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- egov
- 마스킹
- Tomcat
- Ajax
- bulkinsert
- mysql
- JQuery
- jsp
- INSERT
- query
- 정보처리산업기사
- NoSQL
- JAXBContext
- vue.js
- github
- vue Carousel
- MariaDB
- 부스트코스
- checkbox
- spring
- 구멍가게코딩단
- 오라클
- mybatis
- java
- swipe 배너
- JSON
- jdbc
- vscode tutorial
- 기출문제
- insertAll
- Today
- Total
개발새발
[mariaDB] 페이징 쿼리 본문
공통으로 페이징 가져와서 쓴 쿼리
<select id="selectTestList" parameterType="testVO" resultType="testVO"> <include refid="common.pagingTop" /> SELECT a.test_ID, a.TITLE, CONCAT(STR_TO_DATE(a.START_DISP_DT, '%Y%m%d'), ' ~ ', STR_TO_DATE(a.END_DISP_DT, '%Y%m%d')) as startEndDispDT, a.LINK_URL, a.CNTS, a.USE_YN, a.DEL_YN, DATE_FORMAT(a.REG_DT, '%Y-%m-%d') AS REG_DT, b.EMP_NM as REG_NM, a.UPD_DT, a.UPD_NO FROM test a, EMP b <where> a.reg_no = b.emp_no <if test="title != null and title != ''"> AND a.TITLE LIKE '%' #{title} '%' </if> <if test="startDispDt != null and startDispDt != '' and endDispDt != null and endDispDt != ''"> AND STR_TO_DATE(a.start_disp_dt, '%Y%m%d') <![CDATA[>=]]> STR_TO_DATE(replace(#{startDispDt}, '-' , ''), '%Y%m%d') and STR_TO_DATE(a.end_disp_dt, '%Y%m%d') <![CDATA[<=]]> STR_TO_DATE(replace(#{endDispDt}, '-' , ''), '%Y%m%d') </if> <if test="useYn != null and useYn != ''"> AND a.use_yn = #{useYn} </if> AND a.DEL_YN = 'N' </where> <include refid="common.pagingBttom" /> </select> |
공통부분
<mapper namespace="common"> <sql id="pagingTop"> SELECT T3.* FROM ( SELECT @rownum := @rownum+1 AS SEQ , T2.* FROM ( SELECT T1.* , COUNT(*) OVER(PARTITION BY '1') TOT_CNT FROM ( </sql>
<sql id="pagingBttom"> )T1 ORDERY BY ( CASE WHEN '${sort}' = '' THEN REG_DT (컬럼명을 따로 지정 안할때 디폴트 컬럼으로 order by 할 컬럼명) ELSE '${sort}' END ) ${order} )T2, (SELECT @rownum :=0) AS R )T3 WHERE T3.SEQ > #{offset} AND T3.SEQ < = (#{limit}*#{page}) </sql>
</mapper> |
select T3.* from( select T2.* from ( select T1.*, row_number() over(order by user_no desc)as seq from ( select Z.* from ( select row_number() over(order by user_no desc ) as rNum, X.* from ( select USER_NO , USER_ID , USER_TYP , USER_PW from svc_user su )X where X.user_no > 40 )Z )T1 )T2 where T2.seq > 0 -- #{offset} )T3 where T3.seq <= (10*1) -- (#{limit}*#{page}) |
'Data Base > mariaDB' 카테고리의 다른 글
mariaDB in 조건 순서에 맞는 다른 테이블 데이터 가져오기 (0) | 2020.11.30 |
---|---|
[function] 입력받는 모든 글자 마스킹 (0) | 2020.11.10 |
[mysql] mac 한글깨짐 (0) | 2020.11.09 |
[mariaDB] 화폐단위 콤마함수 (0) | 2020.10.30 |