>SQL中条件表达式是指在sql语句中写条件表达式,实现动态拼参 >支持的版本号`version 1.3.79及以上版本` `date 20210813` --- [TOC] ## 演示效果 >`name`和`sex`为空数据全查,`name`不为空只查询`姓名`,`age`不为只查询`年龄`,都不为空就全部查询 ![](https://img.kancloud.cn/f7/78/f778cf792c4006567b581ca6e5566db9_1911x980.png) ## 配置步骤 >在sql语句中填写需要动态传参的条件判断,`sex`不为空则传递`sex`参数,`name`不为空传递参数`name` ![](https://img.kancloud.cn/55/f6/55f6cac9aca465da16c218338933c9f9_1914x898.png) ``` select id,name,age from demo where create_by = '#{sysUserCode}' <#if isNotEmpty(age)> and age= '${age}' </#if> <#if isNotEmpty(name)> and name= '${name}' </#if> ``` 注意: - `isNotEmpty` : `null`和`""`均返回`false` - 语法参考:freemarker - 参数使用的是${}表达式,#{}取的是系统变量,不可混用