Column 'Status' in where clause is ambiguous

我会带着你远行 2023-10-18 09:57 250阅读 0赞

错误提示:

![Image 1][]70

解决:

在Mapper文件中,多表关联查询中有相同的字段,在查询条件里,没有指定别名。

  1. <where>
  2. <if test="customerName"> bub.CustomerName like CONCAT('%',#{customerName},'%' )</if>
  3. <if test="status != null"> and bub.Status = #{status}</if>
  4. <if test="startTime!= null and startTime != ''">AND DATE_FORMAT(bub.transactionTime,'%y-%m-%d') >=DATE_FORMAT( #{startTime},'%y-%m-%d')</if>
  5. <if test="endTime!= null and endTime != ''">AND DATE_FORMAT(#{endTime},'%y-%m-%d')>=DATE_FORMAT(bub.transactionTime,'%y-%m-%d') </if>
  6. </where>

在这里status要加上主表的别名,就可以了。

[Image 1]:

发表评论

表情:
评论列表 (有 0 条评论,250人围观)

还没有评论,来说两句吧...

相关阅读