<!--多条件查询map--> <select id="dtj" resultType="Studentinfo"> SELECT * from studentinfo WHERE stuName LIKE '%' #{stuName} '%' AND stuAge>#{stuAge} </select> <!--多条件查询索引--> <select id="dtjsy" resultType="Studentinfo"> SELECT * from studentinfo WHERE stuName LIKE '%' #{0} '%' AND stuAge>#{1} </select> <!-- 智能标签 if--> <select id="znif" resultType="Studentinfo"> SELECT * from studentinfo <where> <if test="stuName!=null"> AND stuName LIKE '%' #{stuName} '%' </if> <if test="stuAge!=null"> AND stuAge>#{stuAge} </if> </where> </select> <!--//foreach array--> <select id="znforeachArray" resultType="Studentinfo"> SELECT * from studentinfo <where> <if test="array.length>0"> stuId in <foreach collection="array" open="(" close=")" separator="," item="stuId"> #{stuId} </foreach> </if> </where> </select> <!--foreach list(studentinfo)--> <select id="znforeachlistList" resultType="Studentinfo"> select * from studentinfo <where> <if test="list.size>0"> stuId IN <foreach collection="list" open="(" close=")" separator="," item="stu" > #{stu.stuId} </foreach> </if> </where> </select>
mybatis 智能标签+多条件查询
最新推荐文章于 2023-01-03 15:31:44 发布