954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Update statement in SQL

Hi there here is a stupid question. I have created an update statement that updates a table that has null user id using a name as the identifier:

UPDATE dembel
SET userid = 8908
WHERE [Name] = 'o'reily'

However the the name already contains an apostrophe which causes a problem in sql, How can i write the name so that the apostrophe is part of the string itself.

Ziggynet
Newbie Poster
5 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Something like that might work:

UPDATE dembel

SET userid = 8908

WHERE [Name] = 'o''reily'


But before doing that you need to replace the name in ur db with double apostrophe using Replace:

Replace ("o'reily", " ' ", " '' ")
Aussie_Here
Newbie Poster
18 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

Something like that might work:

UPDATE dembel

SET userid = 8908

WHERE [Name] = 'o''reily'

But before doing that you need to replace the name in ur db with double apostrophe using Replace:

Replace ("o'reily", " ' ", " '' ")


Why would he replace the data with a double apostrophe? That's changing the integrity of the data, which I don't think he wants.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

That's one solution and if he doesn't want it he could do sth else but do u have any suggestion in this regard?

Aussie_Here
Newbie Poster
18 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: