스프링

	<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>

 

spring

 

about author

PHRASE

Level 60  머나먼나라

충신은 두 임금을 섬기지 않고, 열녀는 두 지아비를 섬기지 않는다. -왕촉

댓글 ( 4)

댓글 남기기

작성