September 17, 2004 at 4:00 pm
Hi All
How do you search for a name with a ' in it,
eg O'Connor
i tried in Query to search a table for the name, i typed in
=O'Connor
and it shows
SELECT surname
FROM Students
WHERE (surname = 'OConnor')
is there a way to search for names with a ' in them ?
Thanks
Steve
September 18, 2004 at 10:44 am
Try the following:
SELECT Surname
FROM Students
WHERE Surname LIKE 'O%Connor'
or something like this:
--Get ASCII value for character
SELECT ASCII(')
SELECT Surname
FROM Students
WHERE REPLACE(Surname, CHAR(Insert ASCII Value), '') = 'OConnor'
** I havent tested the last example - I am not sat in front of a PC with SQLQA on it, so am guessing a little, but it may help you? **
September 18, 2004 at 11:22 am
Thank you very much,
September 18, 2004 at 12:16 pm
Hi,
You just have to double up the ' as in
select * from test where data = 'O''Connor'
If you are creating the statement dynamically from say a web page you can use the replace function swap each single quote with two singe quotes
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply