我遇到了一个大问题的问题但是试图简化它并发现了类似的奇怪行为:
select concat(a.col1,a.col2) as b,
count(a.id) as c
from test as a
group by a.id
having b = "644591"
order by b
同样的查询在5.6 InnoDB上没有返回结果,但5.5 MyISAM返回一个正确的匹配。
如果你删除“b by order”,它也会在InnoDB上返回正确的结果。
表:
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`col1` varchar(100) NOT NULL DEFAULT '',
`col2` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB
id|col1 |col2
1| |644591
2|70083531|1226109
答案 0 :(得分:0)
怎么样......
select concat(a.col1,a.col2) as b,
count(a.id) as c
from test a
where concat(a.col1,a.col2) = '644591'
group by concat(a.col1,a.col2)
order by b;