MySQL会自动使用空格分割关键字

时间:2018-12-10 09:58:59

标签: mysql

我有一个名为members的下表

+----+--------+--------+-------+--+
| id | name   | gender | state |  |
+----+--------+--------+-------+--+
| 1  | Peter  | M      | 1     |  |
+----+--------+--------+-------+--+
| 2  | Sally  | F      | 1     |  |
+----+--------+--------+-------+--+
| 3  | Martin | M      | 0     |  |
+----+--------+--------+-------+--+

然后,我的查询是

SELECT * FROM `member` WHERE `id` = '1 3';

MySQL返回了| 1 | Peter | M | 1 | |

但是,我希望它不会返回任何内容,因为应该没有id = '1 3'的记录。

如何防止这种情况?

1 个答案:

答案 0 :(得分:1)

尝试使用BINARY

select * from member where BINARY id = '1 3';