๋กœ์ผ“๐Ÿพ
article thumbnail

 

๋งˆ์ด๋ฐ”ํ‹ฐ์Šค์—์„œ๋Š” <sql>๋ฌธ๊ณผ <include>๋ฌธ์„ ์ด์šฉํ•˜์—ฌ sql๋ฌธ์„ ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.

 


l <sql>๊ณผ <include>

 

<sql id="whereParam">
	AND NAME LIKE '%์ง€%'
</sql>

<select id="selectInclude" parameterType="memberVO" resultType="memberVO">
	SELECT
		*
	FROM TEST_TABLE
	WHERE 1=1
	<include refid="whereParam"/>
</select>

 

<sql> ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋งŒ๋“  sql๋ฌธ์€ <include>๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์žฌ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๊ณตํ†ต์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” sql๋ฌธ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.

 

SELECT * FROM TEST_TABLE WHERE 1=1 AND NAME LIKE '%์ง€%';

 

'์ง€'๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” NAME์„ ์ฐพ๋Š” ๊ตฌ๋ฌธ์ด๋ฏ€๋กœ ์œ„ ์ถœ๋ ฅ๊ฒฐ๊ณผ์˜ NAME์ด 'ํ™์ง€์›'์ธ๊ฑธ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์งˆ๋ฌธ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค.

 

"๋‚œ ๋ฐ˜๋“œ์‹œ ๋ฐฑ์—”๋“œ ์™•์ด ๋ ๊ฑฐ์•ผ"

profile on loading

Loading...