复现:
代码语言:sql复制CREATE TABLE `t1` (
`user_id` int DEFAULT NULL,
`name` varchar(10) DEFAULT NULL,
`address` varchar(10) DEFAULT NULL,
KEY `idx_userid` (`user_id`)
) ENGINE=InnoDB
代码语言:sql复制mysql> select * from t1;
--------- ------ ---------
| user_id | name | address |
--------- ------ ---------
| 10 | aa | bj |
| 20 | bb | sh |
| 30 | cc | NULL |
--------- ------ ---------
3 rows in set (0.00 sec)
查询不等于台湾的数据
代码语言:javascript复制mysql> select * from t1 where address != 'taiwan';
--------- ------ ---------
| user_id | name | address |
--------- ------ ---------
| 10 | aa | bj |
| 20 | bb | sh |
--------- ------ ---------
2 rows in set (0.06 sec)
mysql> select * from t1 where address <> 'taiwan';
--------- ------ ---------
| user_id | name | address |
--------- ------ ---------
| 10 | aa | bj |
| 20 | bb | sh |
--------- ------ ---------
2 rows in set (0.00 sec)
按照人类的思维应该返回3条数据,但却返回了2条数据。