学习视频上的动态SQL语句在.xml配置中的使用是
<select id="findUserByCondition" parameterType="com.wz.domain.Demo01" resultType="com.wz.domain.Demo01">
select id,name,birthday,money from user where 1=1
<if test="name != null">
name=#{name}
</if>
</select>
一直报错SQL语句出错,几经波折修改为
<select id="findUserByCondition" parameterType="com.wz.domain.Demo01" resultType="com.wz.domain.Demo01">
select id,name,birthday,money from user
<where>
<if test="name != null">
name=#{name}
</if>
</where>
</select>
成功运行。
再次测试,修改为以下也可以运行
` <select id="findUserByCondition" parameterType="com.wz.domain.Demo01" resultType="com.wz.domain.Demo01">
select id,name,birthday,money from user where 1=1
<if test="name != null">
and name=#{name}
</if>
</select>`