https://github.com/baomidou/mybatis-plus/issues/2585
在使用MP和Shardingsphere的某些版本中,可能会出现join 子查询表 取别名之后,在where中用这个别名报错 Can not find owner from table.
// 重点是外层SQL不要出现 * ,不要使用别名,需要的字段都写清楚(内外层sql都要写清楚),才可以查出数据,不然要么是数据为空,要么是报错 Can not find owner from table. // 正常工作 select resId,resType from ( select id as resId, type as resType from test ) res where resId > 0 GROUP BY resType // 没有数据 select * from ( select id as resId, type as resType from test ) res where resId > 0 GROUP BY resType // 没有数据 select * from ( select * from test )res where id > 0 GROUP BY res.type // IllegalStateException : Can not find owner from table. select * from ( select * from test ) res where res.id > 0 GROUP BY res.type
不用别名.字段,也不给字段取别名,倒是解决了。问题是如果还有其他子查询也是查了个any_value(create_time) 列名就重复了。没有深追这个issue。不知道最新版本修复没
标签:resId,shardingsphere,resType,别名,Plus,res,MyBatis,where,select From: https://www.cnblogs.com/tyt0o0/p/17781854.html