表结构
CREATE TABLE `demo_a` (
`id` varchar(255) NOT NULL,
`code` varchar(255) NOT NULL,
`desc` varchar(255) NOT NULL,
`other` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
初始化数据
INSERT INTO `demo_a` (`id`, `code`, `desc`, `other`) VALUES ('5000000000002675287', 'a', 'a', 'a');
INSERT INTO `demo_a` (`id`, `code`, `desc`, `other`) VALUES ('5000000000002675599', 'b', 'b', 'b');
INSERT INTO `demo_a` (`id`, `code`, `desc`, `other`) VALUES ('5000000000002676160', 'c', 'c', 'c');
INSERT INTO `demo_a` (`id`, `code`, `desc`, `other`) VALUES ('5000000000002676161', 'd', 'd', 'd');
INSERT INTO `demo_a` (`id`, `code`, `desc`, `other`) VALUES ('5000000000002676162', 'e', 'e', 'e');
注意 id 是字符串类型
注:mysql版本
5.6.17-66.0-log
查询1
select * from demo_a where id='5000000000002676160'
结果正确如下:
查询2
select * from demo_a where id=5000000000002676160
结果不正确:
上面的例子在5.7.17-log,两个查询结果都正确。
猜测原因是类型转换过程出错了。但是不清楚为什么,求大神帮忙解释。