sql like模糊查询的条件拼接

sql like模糊查询的条件拼接

 

被坑了两次,记录加深记忆

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>

posted @ 2017-12-26 21:15  喜东东  阅读(6559)  评论(0编辑  收藏  举报