输出一个配合条件为一个整型字段转到二进制后的第三位为1的所有记录

我想输出一个配合条件为一个整型字段转到二进制后的第三位为1的所有记录,有想会写吗?急用.
---------------------------------------------------------------

MySQL-Front Dump 2.5

Host: localhost Database: test2

--------------------------------------------------------

Server version 4.0.12-max-debug-log

Table structure for table 'ta'

CREATE TABLE ta (
id int(3) unsigned NOT NULL auto_increment,
PRIMARY KEY (id)
) TYPE=MyISAM;

Dumping data for table 'ta'

INSERT INTO ta VALUES("1");
INSERT INTO ta VALUES("2");
INSERT INTO ta VALUES("3");
INSERT INTO ta VALUES("4");
INSERT INTO ta VALUES("5");
INSERT INTO ta VALUES("6");
INSERT INTO ta VALUES("7");
INSERT INTO ta VALUES("8");
INSERT INTO ta VALUES("9");
INSERT INTO ta VALUES("10");
INSERT INTO ta VALUES("11");
INSERT INTO ta VALUES("12");
INSERT INTO ta VALUES("13");
INSERT INTO ta VALUES("14");

mysql> SELECT * FROM ta WHERE (id >> 2) & 1;
+----+
¦ id ¦
+----+
¦ 4 ¦
¦ 5 ¦
¦ 6 ¦
¦ 7 ¦
¦ 12 ¦
¦ 13 ¦
¦ 14 ¦
+----+
7 rows in set (0.01 sec)

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus