记录报错不知道属性是在哪个表中的

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'tid' in where clause is ambiguous

记录报错显示不知道tid是哪个表中的数据

  <select id="mohu" resultType="com.bwie.entity.Goods">
        select * from goods g left join shoptype s on g.tid=s.tid
        <where>
            <if test="vo.name!=null and vo.name!=''">
                and name = #{vo.name}
            </if>
            <if test="vo.brief!=null and vo.brief!=''">
                and brief = #{vo.brief}
            </if>
            <if test="vo.tid!=null and vo.tid!=''">
                and tid = #{vo.tid}
            </if>
            <if test="vo.start!=null and vo.start!=''">
                and price = #{vo.start}
            </if>
            <if test="vo.end!=null and vo.end!=''">
                and price = #{vo.end}
            </if>
        </where>
        order by g.shopnum desc
    </select>

  修改后

  <select id="mohu" resultType="com.bwie.entity.Goods">
        select * from goods g left join shoptype s on g.tid=s.tid
        <where>
            <if test="vo.name!=null and vo.name!=''">
                and name = #{vo.name}
            </if>
            <if test="vo.brief!=null and vo.brief!=''">
                and brief = #{vo.brief}
            </if>
            <if test="vo.tid!=null and vo.tid!=''">
                and s.tid = #{vo.tid}
            </if>
            <if test="vo.start!=null and vo.start!=''">
                and price = #{vo.start}
            </if>
            <if test="vo.end!=null and vo.end!=''">
                and price = #{vo.end}
            </if>
        </where>
        order by g.shopnum desc
    </select>

  这样报错就解决了

posted on 2022-01-09 15:06  菊_酒  阅读(34)  评论(0)    收藏  举报