faqts : Computers : Programming : Languages : Sql

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

60 of 69 people (87%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How do I construct select statements where the string in the where clause has an apostrophe? Ex: SELECT * FROM customers WHERE name like 'Bob's%';

Sep 2nd, 2005 19:23
Rohit Kulkarni, Michael Vickers, Jackie Nguyen,


Try using double apostrophes. For instance, in T-SQL:
select idProfile from tblProfiles where strAddS1 like '%''%'
This select statement in one of my SQL Server DB's will return all IDs 
in a particular table where there is an apostrophe somewhere in the 
street address field.
So, for your particular select statement I would try:
SELECT * FROM customers WHERE name like 'Bob''s%'
Good luck.
Michael
--------------------------------
Two single quotes will work in case of PL/SQL too
-Rohit.
--------------------------------