Reputation: 11375
I have one table with some email addresses. The address is of course a string, which I've set up on table creation as VARCHAR(100) DEFAULT NULL.
Now, when I use:
SELECT * FROM emails;
It works fine, if I also select using ID's, it works fine
SELECT * FROM emails WHERE id = 1;
But if I try to find a particular email
SELECT * FROM emails WHERE address = '[email protected]'
It simply doesn't work. It returns no rows matching this, but there is a row matching, because it appears on the SELECT * FROM emails
query.
What can be happening here? Why the WHERE clause is not working?
EDIT: The data came from the following import
LOAD DATA LOCAL INFILE 'c:/users/user/dev/mysql/emails.txt'
INTO TABLE emails
FIELDS terminated by ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(address)
Upvotes: 1
Views: 4348
Reputation: 3846
There may be leading or trailing characters in the field. Try this:
SELECT * FROM emails WHERE address LIKE '%[email protected]%'
Upvotes: 3