1)BoardMapper
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.spring.board.dao.BoardMapper">
<select id="selectRowCount" parameterType="map" resultType="integer">
SELECT COUNT(*) FROM spboard b JOIN spmember m ON b.mem_num=m.mem_num
<where>
<if test="keyword != '' and keyfield == 'title'">
b.title LIKE '%' || #{keyword} || '%'
</if>
<if test="keyword != '' and keyfield == 'id'">
m.id LIKE '%' || #{keyword} || '%'
</if>
<if test="keyword != '' and keyfield == 'content'">
b.content LIKE '%' || #{keyword} || '%'
</if>
</where>
</select>
<select id="selectList" parameterType="map" resultType="boardVO">
SELECT * FROM (SELECT a.*, rownum rnum FROM
(SELECT * FROM spboard b JOIN spmember m ON b.mem_num=m.mem_num
<where>
<if test="keyword != '' and keyfield == 'title'">
b.title LIKE '%' || #{keyword} || '%'
</if>
<if test="keyword != '' and keyfield == 'id'">
m.id LIKE '%' || #{keyword} || '%'
</if>
<if test="keyword != '' and keyfield == 'content'">
b.content LIKE '%' || #{keyword} || '%'
</if>
</where>
ORDER BY b.num DESC) a
)<![CDATA[ WHERE rnum >= #{start} AND rnum <= #{end} ]]>
</select>
</mapper>
2)실행 및 오류체크
반응형
'IT > Java Spring' 카테고리의 다른 글
ch10.SpringMVC 종합 16.조회수 증가 (0) | 2020.06.29 |
---|---|
ch10.SpringMVC 종합 15.디테일 (0) | 2020.06.29 |
ch10.SpringMVC 종합 13. 목록작업 (0) | 2020.06.26 |
ch10.SpringMVC 종합 12. 게시판 글쓰기 (0) | 2020.06.26 |
ch10.SpringMVC 종합 11. 게시판 (0) | 2020.06.25 |