Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quote in a string : query problem 2

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
0
0
FR
hi all,
i'm a begginer in SQL so can someone help me ?

i have this problem :
i have a query that searches all contacts that have a name that begins with a specified letter.

if the user looks for all the contacts that begin with the "tr" string :
SELECT ContactName FROM CONTACTS WHERE ContactLName Like 'tr%' ORDER BY ContactLName;

here is no problem

the problem is when the contact has a name like o'conneil for exemple ... because it gives something like :

if the user looks for all the contacts that begin with the "o'" string:
SELECT ContactName FROM CONTACTS WHERE ContactLName Like 'o'%' ORDER BY ContactLName;

you see the problem ? the quote in the contact name is a problem because under VB in the query the quote is used for a string delimitation ...
but the contact name is entered like " o'conneil " in the database ...
what can i do ?


ps : sorry for my bad english
Best regards,
Elise
 
All you have to do is add another apostrophy.

replace(string,"'","''")

example: search for "O''Connell"
 
thanks that works Best regards,
Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top