慕粉1940095621
2017-08-17 10:33
类似mybaits
whereid=#{id}
<if test="createTimeStart!=null">
AND p.create_time >= #{createTimeStart}
</if>
<if test="createTimeEnd!=null">
AND p.create_time <= #{createTimeEnd}
</if>
可以看看这两种方法: (1)@Query( value = "SELECT * FROM sys_customer WHERE 1=1 " + " AND if(:name!='',name LIKE CONCAT('%',:name,'%'),1=1)", nativeQuery = true) (2)@Query(value = "SELECT * FROM sys_customer WHERE 1=1 "+ " AND (name LIKE CONCAT('%',:name,'%') OR :name IS NULL )", nativeQuery = true) List<Customer> findDate(@Param("name") String name);
轻松愉快之玩转SpringData
34089 学习 · 119 问题
相似问题