Home » SQL & PL/SQL » SQL & PL/SQL » How can i insert or search for single quotes( ' )?
How can i insert or search for single quotes( ' )? [message #216227] Thu, 25 January 2007 12:45 Go to next message
Rustican
Messages: 51
Registered: July 2006
Member
If i had a string 'Hello World' where the quotes are part of the string. How can do a search on it?

select * from table where mystring = ''Hello World'';
doesn't work.

also tried
"'Hello World'"

Is there a way to force oracle to accept ' as part of a string?
Re: How can i insert or search for single quotes( ' )? [message #216230 is a reply to message #216227] Thu, 25 January 2007 12:47 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
scott@9i > select * from t1;

C1
----------------------------------------------------------------------------------------------------
'HELLO wORLD'

scott@9i > select * from t1 where c1='''HELLO wORLD''';

C1
----------------------------------------------------------------------------------------------------
'HELLO wORLD'

scott@9i > select * from t1 where c1 like ('%HELLO wORLD%');

C1
----------------------------------------------------------------------------------------------------
'HELLO wORLD'

Re: How can i insert or search for single quotes( ' )? [message #216892 is a reply to message #216227] Tue, 30 January 2007 15:48 Go to previous message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
If it wasn't clear, to specify a single quote within a quoted string, simply use 2 single quotes next to each other. For example

insert into my_table values('this isn''t a test');

select * from my_table where col_a like '%''%';

Previous Topic: help on sql query
Next Topic: date format?
Goto Forum:
  


Current Time: Sun Dec 04 10:47:24 CST 2016

Total time taken to generate the page: 0.05616 seconds