您可以使用按位AND运算符(&
),AND
和NOT 2(使用按位取反运算符(~
创建)来获取结果,例如
CREATE TABLE test (num BIGINT(20));
INSERT INTO test VALUES
(4),
(91),
(9223372036854775807);
SELECT num, num & ~2 FROM test;
输出:
num num & ~2
4 4
91 89
9223372036854775807 9223372036854775805
Demo on dbfiddle