标签:test int ring @param sel mooc sql 语句 十分 pre
在注解中使用动态 SQL 其实十分简单,只需在动态 SQL 语句的外面包上一层script标签即可。如下:
@Select({"<script>",
"SELECT * FROM imooc_user",
" WHERE",
" <choose>",
" <when test=‘id != null‘>",
" id = #{id}",
" </when>",
" <when test=‘username != null‘>",
" username = #{username}",
" </when>",
" <otherwise>",
" 1 = 0",
" </otherwise>",
" </choose>",
"</script>"})
User selectUserByIdOrName(@Param("id") Integer id, @Param("username") String username);
标签:test int ring @param sel mooc sql 语句 十分 pre
原文地址:https://www.cnblogs.com/qiuwenli/p/13413309.html