1. 程式人生 > >sql like模糊查詢的條件拼接

sql like模糊查詢的條件拼接

body con ted cond -c where sel apple b-

被坑了兩次,記錄加深記憶

oracle :

select * from table_name where 1=1

<#if secondName?? && secondName?has_content>

and second_name like ‘%‘||:secondName||‘%‘

</#if>

mysql:

 select * from table_name where 1=1

<#if secondName?? && secondName?has_content>

and second_name like concat(‘%‘, :second_name ,‘%‘)

</#if>

sql like模糊查詢的條件拼接