I have a database table with email addresses with apostrophe such as "some.o'[email protected]".
I would like to:
- Query this table, and check if this email address exist
- insert this email address if it doesn't exist in the table
I tried:
SELECT *
FROM EMAILTABLE
WHERE emailaddress LIKE 'some.o''[email protected]'
it doesn't find "some.o'[email protected]", so it's treating it as it doesn't exist!
Double-quotes around some text indicates you are looking for an object name, unless you are embedding the double-quotes within single-quotes.
So:
In the second test, it's assuming that "some.o'[email protected]" is a column, because it's a name inside double-quotes.
You can see from the first and third tests that the presence of the double-quotes inside the string are saying that these strings are different. The first one is the same as the value in the table. The other one isn't.
Anyway, I think the simplest way to handle is with a unique index on the emailaddress. If you then try to insert the same value that already exists, it won't do anything.