欢迎关注方志朋的博客,回复”666“获面试宝典读完这篇文章里你能收获到Mybatis动态SQL语句大全Mybatis中如何定义变量Mybatis中如何提取公共的SQL片段1. If 语句需求:根据作者名字和博客名字来查询博客!如果作者名字为空,那么只根据博客名字查询,反之,则根据作者名来查询根据作者名字和博客名字来查询博客!如果作者名字为空,那么只根据博客名字查询,反之,则根据作者名来查询select * from blog where title = #{title} and author = #{author}-->select id="queryBlogIf" parameterType="map" resultType="blog"> select * from blog where if test="title != null"> title = #{title} if> if test="author != null"> and author = #{author} if>select>这样写我们可以看到,如果 author 等于 null,那么查询语句为 select * from user where title=#{title},但是如果title为空呢?那么查询语句为
………………………………