CREATE or replace TABLE `t1` ( `b` bigint(20) unsigned PRIMARY KEY ) ENGINE=MyISAM DEFAULT CHARSET=utf8; select count(*), (0xffffffffffffffff DIV 8)*4, (0xffffffffffffffff DIV 8) *5-1 from t1 where b between (0xffffffffffffffff DIV 8)*4 and (0xffffffffffffffff DIV 8)*5-1; insert ignore into t1(b) select rand()*0xffffffffffffffff from seq_1_to_100000; select min(b), max(b) from t1; select count(*), (0xffffffffffffffff DIV 8)*4, (0xffffffffffffffff DIV 8) *5-1 from t1 where b between (0xffffffffffffffff DIV 8)*4 and (0xffffffffffffffff DIV 8)*5-1; select count(*), 9223372036854775804, 11529215046068469754 from t1 where b between 9223372036854775804 and 11529215046068469754; select min(b), min(b) <= 11529215046068469754 from t1 where b >= 9223372036854775804; select count(*), (0xffffffffffffffff DIV 8)*4, cast(cast(0xffffffffffffffff as unsigned) DIV 8 as unsigned)*5-1 from t1 where b between (0xffffffffffffffff DIV 8)*4 and (0xffffffffffffffff DIV 8)*5-1; explain select count(*), (0xffffffffffffffff DIV 8)*4, cast(cast(0xffffffffffffffff as unsigned) DIV 8 as unsigned)*5-1 from t1 where b between (0xffffffffffffffff DIV 8)*4 and (0xffffffffffffffff DIV 8)*5-1; select count(*), (0xffffffffffffffff DIV 8)*4, (0xffffffffffffffff DIV 8)*5-1 from t1 where b >= (0xffffffffffffffff DIV 8)*4 and b <= (0xffffffffffffffff DIV 8)*5-1; explain select count(*), (0xffffffffffffffff DIV 8)*4, (0xffffffffffffffff DIV 8)*5-1 from t1 where b >= (0xffffffffffffffff DIV 8)*4 and b <= (0xffffffffffffffff DIV 8)*5-1; truncate table t1; select count(*), (0xffffffffffffffff DIV 8)*4, cast(cast(0xffffffffffffffff as unsigned) DIV 8 as unsigned)*5-1 from t1 where b between (0xffffffffffffffff DIV 8)*4 and (0xffffffffffffffff DIV 8)*5-1; select count(*), (0xffffffffffffffff DIV 8)*4, (0xffffffffffffffff DIV 8)*5-1 from t1 where b >= (0xffffffffffffffff DIV 8)*4 and b <= (0xffffffffffffffff DIV 8)*5-1; SELECT 'Extra strangeness'; select hex(9223372036854775807); select count(*),9223372036854775807+4 from t1 where b>1; select count(*),9223372036854775808+4 from t1 where b>1; drop table t1;