<sql id="criteria"> <trim prefix="and(" suffix=") " prefixOverrides="OR"> <foreach item='type' collection="typeArr"> <trim prefix="OR"> <choose> <when test="type== 'T'.toString()"> post_title like '%' || #{keyword}||'%' </when> <when test="type== 'C'.toString()"> post_content like '%' || #{keyword}||'%' </when> <when test="type== 'W'.toString()"> post_writer like '%' || #{keyword}||'%' </when> </choose> </trim> </foreach> </trim> </sql> <select id="selectboardList" resultType="board"> select * from (select rownum rno,b.* from board_post b where isshow != 'N' <include refid="criteria"></include> order by post_no desc ) where rno between (#{pageNum}-1)*#{amount}+1 and (#{pageNum})*#{amount} </select>