Home » SQL & PL/SQL » SQL & PL/SQL » How can I find records which contains: '
How can I find records which contains: ' [message #203993] Fri, 17 November 2006 04:37 Go to next message
reedar
Messages: 2
Registered: November 2006
Junior Member
Hi, new to this forum so hoping someone can help me out.

I have a database which contains many names like "Steve D'Arcy".

How can I word a select so that it only returns the records which have a ' in the surname?
At the moment as soon as I type the character ' it closes the statement.

Many thanks all!

Daz
Re: How can I find records which contains: ' [message #203994 is a reply to message #203993] Fri, 17 November 2006 04:40 Go to previous messageGo to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
select * from table
 where surname like '%''%';
Re: How can I find records which contains: ' [message #203995 is a reply to message #203993] Fri, 17 November 2006 04:45 Go to previous messageGo to next message
reedar
Messages: 2
Registered: November 2006
Junior Member
mate, that is brilliant! Cheers.

New to this whole SQL world so currently finding myself on a v steep learning curve at work!

Thanks again
Daz
Re: How can I find records which contains: ' [message #203996 is a reply to message #203995] Fri, 17 November 2006 04:47 Go to previous messageGo to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
Just append another single quote at the quote character. So if you're looking for surnames which have ''' (3 quotes), then your condition would be:
where surname like '%''''''%';
Wink
Re: How can I find records which contains: ' [message #204012 is a reply to message #203996] Fri, 17 November 2006 05:38 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Or you could use the ascii value, and avoid all the confusion

WHERE SURNAME LIKE '%'||chr(39)||'%'
or
WHERE INSTR(SURNAME,chr(39)) > 0
Previous Topic: track stored procedures and functions that are "used" in a schema
Next Topic: load/select data into subpartition
Goto Forum:
  


Current Time: Tue Dec 06 15:53:24 CST 2016

Total time taken to generate the page: 0.06871 seconds