<select id="queryEmp" resultType="entity.Emp" parameterType="Map">? ? ? select?? ? ? ? <include refid="empColumns"></include>? ? ? ? <!-- ?-->? ? ? ? from e_emp e where 1=1 //這里為什么添加1=1 ?請(qǐng)解釋一下。謝謝!? ? ? ??? ? ? ? <if test="name!=null and name!=''">? ? ? ? ? ? and e.ename like '%${name}%'? ? ? ? </if>? ? ? ??? ? ? ? <if test="sex != '全部'">? ? ? ? ? ? and e.esex = #{sex}? ? ? ? </if>? ? ? ??? ? ? ? <if test="marge != 2">? ? ? ? ? ? and e.emarge = #{marge}? ? ? ? </if>? ? ? ????? </select>
2 回答

Caballarii
TA貢獻(xiàn)1123條經(jīng)驗(yàn) 獲得超629個(gè)贊
如果沒(méi)有1=1,那么語(yǔ)句里很可能出現(xiàn)where和and相連的情況,語(yǔ)法就報(bào)錯(cuò)了
添加回答
舉報(bào)
0/150
提交
取消