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

 

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

0.0.2.  


1. l ๊ณผ

 

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

 

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

 

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

 

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

 

 

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

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

 

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