<sql id="search">
<choose>
<when test="#{search_option == 'all'}">
<!-- 전체검색 -->
where writer like '%' || #{keyword} || '%'
or content like '%' || #{keyword} || '%'
or title like '%' || #{keyword} || '%'
</when>
<otherwise><!-- 전체 검색이 아닐 때 -->
where ${search_option} like
'%' || #{keyword} || '%'
</otherwise>
</choose>
</sql>
<!-- 레코드 개수 계수 -->
<select id="countArticle" resultType="int">
select count(*) from tbl_board where bno > 0
<include refid="search"></include>
</select>
<sql id="search">
<if test="search_option !=null">
<if test="search_option =='title' || search_option =='writer' || search_option=='content' ">
and ${search_option} like '%' || #{keyword} || '%'
</if>
</if>
<if test="search_option == 'all'">
and ( title like '%' || #{keyword} || '%' )
or ( writer like '%' || #{keyword} || '%' )
or ( content like '%' || #{keyword} || '%' )
</if>
</sql>
<select id="boardList" resultType="BoardVO">
select * from tbl_board where bno > 0
<include refid="search"></include>
order by bno desc, regdate desc
</select>
댓글 ( 4)
댓글 남기기