Solved

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

Posted on 2004-03-31
2
358 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
A short film showing how OnPage and Connectwise integration works.

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now