Chaska
Chaska

Reputation: 3205

MySQL split keyword with space automatically

I'm having a below table called members

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

Then, my query is

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

MySQL returned | 1 | Peter | M | 1 | |.

However, I expect that it would return nothing because there should be no record with id = '1 3'.

How can I prevent this?

Upvotes: 0

Views: 20

Answers (1)

Frank AK
Frank AK

Reputation: 1781

Try to use BINARY

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

Upvotes: 1

Related Questions