转自:
下文笔者讲述mybatis动态sql条件查询的使用简介说明,如下所示
例:
@Select("")
相关参数说明
templateCode:参数信息 table_name:表名 template_code:数据库列名
以上脚本的功能
当传入templateCode为空时
则运行sql
select * from table_name
where 1=1
and (template_code IS NULL or template_code='');
当传入的templateCode不为空时
则运行sql
select * from table_name
where 1=1
and template_code = #{templateCode};