개인적인 정리

LIKE 사용법 본문

DB/MYSQL-IBATIS

LIKE 사용법

yeon.Biju 2016. 8. 23. 16:27

오라클은 

like '%'||#value#||'%' 


Mysql은 

like concat('%','#value#','%') 


Sysbase, SQL SERVER

like '%' + #value# + '%'





예제)

<![CDATA[

SELECT COUNT(*) AS CNT 

FROM 

aaaaaa A, 

bbbbbbbb B 

WHERE A.aaa = B.bbb

]]>

<isNotEmpty property="searchKeyword" prepend=" AND ">

$searchCondition$ LIKE CONCAT('%',#searchKeyword#,'%')

</isNotEmpty> 






<![CDATA[
SELECT * FROM (
SELECT 
aaaaa
bbbbbbbbb
FROM 
aaaaaaaaaaaaaaa A, 
bbbbbbbbbbbbbbb B 
WHERE 
A.aaaa = B.bbbb 
ORDER BY aaaa DESC
)Z
WHERE 1=1
]]>  
<isNotEmpty property="searchKeyword" prepend=" AND ">
$searchCondition$ LIKE CONCAT('%',#searchKeyword#,'%')
</isNotEmpty>
<![CDATA[  
ORDER BY aaaaaa DESC LIMIT #firstIndex#, #recordCountPerPage#
]]> 


Comments