mysql中遇到的奇怪问题

创建表

1
2
3
4
CREATE TABLE `testtable` (
`id` varchar(32) DEFAULT NULL,
`num` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

插入数据

1
2
3
4
5
INSERT INTO `testtable` VALUES ('111111111111', '1');
INSERT INTO `testtable` VALUES ('222222222222', '0');
INSERT INTO `testtable` VALUES ('333333333333', '0');
INSERT INTO `testtable` VALUES ('444444444444', '0');
INSERT INTO `testtable` VALUES ('555555555555', '1');

查询语句

1
2
3
4
--语句1
select * from testtable where num ="r"="fff";
--语句2
select "r"="t" ;

语句1中 查询结果为

id num
111111111111 1
555555555555 1

语句2结果为

“r”=”t”
0

分析:按照网上查找的说法
select from testtable where num =”r”=”fff”;
中会执行顺序为先执行括号中的
select
from testtable where num = (“r”=”fff”);
select “r”=”t” ;查询结果为 0;
按理说语句1应该对应 select from testtable where num = 0;
但是查出来的结果为 select
from testtable where num = 1;的执行结果。

这种问题是什么原因?