Sql中可将重复的sql提取出来,使用时用include引用即可,最终达到sql重用的目的,如下: <select id="findUserByNameAndSex" parameterType="com.huida.po.User" resultType="com.huida.po.User"> <!-- select * from user where 1=1 and username like "%${usern
MyBatis中对数据库的操作,有时要带一些条件,因此动态SQL语句非常有必要,下面就主要来讲讲几个常用的动态SQL语句的语法 MyBatis中用于实现动态SQL的元素主要有: if choose(when,otherwise) trim where set foreach 1.if 对属性进行判断,如果不为空则执行判断条件 <select id="selectByCriteria" parameterType="com.mucfc.dto.Student"