Solved

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

Posted on 2004-03-31
2
357 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
Comment Utility
Just prefix your quotes with a backslash :

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

0
 

Author Comment

by:shaileshmark
Comment Utility
Thanks very much Alf666
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now