1.if+where <select id="getgoods" resultType="Goods" > select * from goods <where> <if test="name!=null and name!=' ' "> and name concat('%',#{name},'%') </if> <if test="条件"> and ..... &
1.MyBatis的动态SQL是基于OGNL表达式的,它可以帮助我们方便的在SQL语句中实现某些逻辑. 2.MyBatis中用于实现动态SQL的元素主要有 if choose(when,otherwise) trim where set foreach 可以看出MyBatis的动态SQL的标签元素和接近JSP中的JSTL语法,下面我就分别详细的介绍一下 3.动态SQL中if的用法 <?xml version="1.0" encoding="UTF-8" ?&g
//-------------------------------查询-------------------------------------// <sql id="cmsGuestbookColumns"> a.id AS "id", a.GROUP_NUMBER AS "groupNumber", a.GROUP_NAME AS "groupName", a.GROUP_AMOUNT as "gro