Molet

mysql oracle sql like模糊查询的条件拼接

Molet 业内资讯 2023-02-27 756浏览 0

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

oracle :

  select * from table_name where 1=1 

p.p1 { margin: 0; font: 14px Monaco }
span.Apple-tab-span { white-space: pre }

 <#if secondName?has_content> 

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

</#if>

 

mysql:

 select * from table_name where 1=1 

 <#if secondName?has_content> 

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

</#if>

继续浏览有关 数据库技术文章/教程 的文章
发表评论