Q
Manage Learn to apply best practices and optimize your operations.

How to return rows that show names with apostrophes

Hi Rudy, Nice site. Just like to know how I can return rows from my database that show the names in my Name column...

that have an apostrophe in them,

ie. select *
    from Contacts
    where FamilyName like '%'%'

Obviously this statement is invalid as I don't know how to express the apostophe. Your help would be gratefully appreciated.

Bradley


Hi Bradley

Assuming this is SQL/Server, you can use either single or double quotes to delimit a string, so in this case, use double quotes so that you can have a single quote as part of the string --

select *
  from Contacts
 where FamilyName like "%'%"

For More Information


This was last published in May 2001

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close