<sql id="search">
<if test="searchType != null" >
<if test="searchType == 't'.toString()">
and title like '%'|| #{keyword}||'%'
</if>
<if test="searchType == 'c'.toString()">
and content like '%'|| #{keyword}||'%'
</if>
<if test="searchType == 'w'.toString()">
and writer like '%'|| #{keyword}||'%'
</if>
<if test="searchType == 'tc'.toString()">
and ( title like '%'|| #{keyword}||'%' OR content like '%'|| #{keyword}||'%')
</if>
<if test="searchType == 'cw'.toString()">
and ( content like '%'|| #{keyword}||'%' OR writer like '%'|| #{keyword}||'%')
</if>
<if test="searchType == 'tcw'.toString()">
and ( title like '%'|| #{keyword}||'%'
OR
content like '%'|| #{keyword}||'%'
OR
writer like '%'|| #{keyword}||'%')
</if>
</if>
</sql>
<select id="listSearch" resultType="org.zerock.domain.BoardVO">
<![CDATA[
select
bno, title, content, writer, viewcnt, regdate
from
(
select
/*+INDEX_DESC(tbl_board, pk_board)*/
rownum rn, bno, title, content, writer, viewcnt, regdate
from tbl_board
where 1=1
]]>
<include refid="search"></include>
<![CDATA[
and rownum <= #{page} * #{perPageNum}
and bno > 0
)
where rn > (#{page} -1) * #{perPageNum}
]]>
</select>
<select id="listSearchCount" resultType="int">
<![CDATA[
select
count(bno)
from
tbl_board
where 1=1
]]>
<include refid="search"></include>
<![CDATA[
and bno > 0
]]>
</select>