【问题标题】:MYSQL doesn't compare big int(20) properlyMYSQL 不能正确比较 big int(20)
【发布时间】:2014-06-07 06:22:24
【问题描述】:

我是 mysql 新手...我有一个表 'table1',其中列 'item_no' 是 bigint(20)。当我尝试根据 item_no 从表中选择特定行时,它不会返回确切的行。相反,它返回一组与前几个字符匹配的行。为什么会这样以及我的查询应该如何获得确切的行。

table1
----------
item_no BIGINT(20) --> Primary key
value VARCHAR(40)

我的表中有以下 item_no 值

item_no                value
----------
10000000161402118444   blah
10000000161402118613   blah
10000000161402118984   blah
10000000161402119080   blah
10000000161402119151   blah
10000000161402119275   blah
10000000161402119680   blah
10000000161402119866   blah
10000000161402119946   blah

这是我的查询

SELECT item_no FROM table1 WHERE item_no = 10000000161402119946

预期结果

item_no
----------
10000000161402119946

但我的查询返回以下内容:

item_no
----------
10000000161402119275
10000000161402119680
10000000161402119866
10000000161402119946

我无法弄清楚...请帮帮我....

【问题讨论】:

标签: mysql compare bigint


【解决方案1】:

你的数字超过了 bigint 的limit。 如果您使您的字段未签名,那么它会起作用。

create table biginttest2 (id bigint unsigned);

【讨论】:

  • 但是为什么它没有出现10000000161402119151 10000000161402119080即使这两个匹配表达式..?
  • @PrathapB,这对我来说也是个谜。我怀疑 mysql 引擎试图匹配尽可能多的二进制数字
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-30
  • 1970-01-01
  • 2016-03-26
  • 2017-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多