Mycat-Server
Mycat-Server copied to clipboard
group by后进行inner join连表后数据不对
1、bug描述 从表A数据中找最大的,表A做了分片,再关联表A找出最大出现的时间。 select stationId,val,time as maxTime from A as a inner join (select stationId,max(val) val from A as a where a.time between '' and '' group by stationId) b on a.stationId=b.stationId and a.val = b.val where a.time between '' and ''
最后返回的结和预期的不对,产生了多个分片表的数。
2、版本号(非常重要) v 1.6.7.6
3、相关表的配置信息 schema.xml (需包含表的配置信息,mysql的连接驱动是JDBC还是native方式) rule.xml (涉及到的路由函数) server.xml(可选)
4、操作步骤
- '...'
- '....'
- ...
5、期望结果 A clear and concise description of what you expected to happen.
6、实际结果 A clear and concise description of what actually happened.
7、额外信息 Add any other context about the problem here.
分表还是分库?如果确定数据都在同一个分片,可以尝试使用注释路由使它们在同一个分片
分库,时间范围超月,就是不同库中,导致问题。
改写下sql,去掉子查询,在代码中去inner join,