讨论数量:
看代码感觉应该是数据类型不对导致的自动转换,可以把查询的数字变成字符串,应该就能解决问题.
select '6920533939703649410' + 0, '6920533939703649419' + 0, cast('6920533939703649410' as double)
你的 order_no 是 int 类型么? 不是 int 类型你用 int 类型去查什么?
When an operator is used with operands of different types, type conversion occurs to make the operands compatible. Some conversions occur implicitly.
If one or both arguments are NULL, the result of the comparison is NULL, except for the NULL-safe <=> equality comparison operator. For NULL <=> NULL, the result is true. No conversion is needed.
If both arguments in a comparison operation are strings, they are compared as strings.
If both arguments are integers, they are compared as integers.
Hexadecimal values are treated as binary strings if not compared to a number.
If one of the arguments is a TIMESTAMP or DATETIME column and the other argument is a constant, the constant is converted to a timestamp before the comparison is performed. This is done to be more ODBC-friendly. This is not done for the arguments to IN(). To be safe, always use complete datetime, date, or time strings when doing comparisons. For example, to achieve best results when using BETWEEN with date or time values, use CAST() to explicitly convert the values to the desired data type.
除此之外,还需要注意,如果字段类型是 varchar、char 等字符串类型时,如果你给定一个数字值去查询时,会导致这一列无法走到索引,反之却不会。
看代码感觉应该是数据类型不对导致的自动转换,可以把查询的数字变成字符串,应该就能解决问题.