MyloverC
2016-08-30 10:44
采纳率: 66.7%
浏览 1.8k
已采纳

mapper.xml sql查询语句报错 重复列名


select ut.*,

uw.nickname,

(CASE WHEN u.role='0' THEN '注册会员' WHEN u.role='1' THEN '认证会员' WHEN  u.role='2' THEN '认证师' WHEN u.role='3' THEN '认证商' WHEN u.role='6' THEN '非会员' END) role3,
(CASE WHEN ut.newRole='0' THEN '注册会员' WHEN ut.newRole='1' THEN '认证会员' WHEN  ut.newRole='2' THEN '认证师' WHEN ut.newRole='3' THEN '认证商' WHEN ut.newRole='6' THEN '非会员' END) newRole

FROM usertarget ut LEFT JOIN usersweixininformation uw
ON ut.openid=uw.openid 

LEFT JOIN userinfo u  
ON ut.openid = u.openid 
ORDER BY ut.time desc

</select>

报错
### Error querying database.  Cause: java.sql.SQLException: null,  message from server: "Duplicate column name 'nickname'"

The error may exist in mybatis/Target.xml

The error may involve com.flf.mapper.TargetMapper.listPageTarget-Inline

The error occurred while setting parameters

Cause: java.sql.SQLException: null, message from server: "Duplicate column name 'nickname'"

; bad SQL grammar []; nested exception is java.sql.SQLException: null, message from server: "Duplicate column name 'nickname'"

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • IT-小崔 2016-08-30 14:56
    已采纳

    你连接的两张表(ut、uw)中可能都有nickname这个列,为每个nickname取个别名

    打赏 评论

相关推荐 更多相似问题