Solved

MySQL query to manipulate varchar or text data types with an apostrophe (') in the data

Posted on 2004-03-31
2
359 Views
Last Modified: 2012-06-21
Experts:
I am trying to update data that has an apostrophe character ' in the character string like -- Dreamin' Out Loud , and Eatin' Right And Drinkin' Bad -- these are album titles. but when i use a sql query in MySQL such as the following:

update ppsong
set AlbumID = '17'
where Title = 'Eatin' Right And Drinkin' Bad';
 
I get the following error:

Error Code : 1064
You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Right And Drinkin' Bad'' at line 3
(0 ms taken)

I get the same error whenever I try to use queries involving data that has an apostrophe in it -- Children's books, Swingin' Blues, etc. Is there any other way i can perform such updates or retrieve such data? Thanks very much.
0
Comment
Question by:shaileshmark
2 Comments
 
LVL 9

Accepted Solution

by:
Alf666 earned 500 total points
ID: 10724823
Just prefix your quotes with a backslash :

update ppsong
set AlbumID = '17'
where Title = 'Eatin\' Right And Drinkin\' Bad';

0
 

Author Comment

by:shaileshmark
ID: 10725154
Thanks very much Alf666
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question