[Every derived table must have its own alias] 在编写mybatis mapper文件时出现的sql错误
直译:每个派生类出现的表必须有一个自己的别名
出现问题场景:多个表关联,且需要查询一个中间表,在编写mybatis mapper文件时出现的错误
解决问题后的sql:
@Select(" select * from ( select source.*,target.dept_name as userDept, target1.dict_name as sexName, group_concat(t2.role_name) as roleNames" +
" from sys_user source " +
" left join sys_dept target on source.dept_id = target.id and target.is_delete=0 " +
" left join sys_dict target1 on source.sex = target1.code and target1.parent_code = 'sex' " +
" left join sys_role_user t1 on source.id = t1.user_id " +
" left join sys_role t2 on t1.role_id = t2.id " +
" group by source.id,userDept,sexName ) as t3" +
" ${ew.customSqlSegment}")

浙公网安备 33010602011771号