MySQL: Handling special characters

This entry is part 10 of 26 in the series Learn MySQL

We always encounter special characters such as quotes or backslashes in a string of characters.

Say we need to insert an album with the title Tha’s Life.

It contains a single quote and to make the statement legal, the quote could be escaped by preceding it with a backslash or a  single quote.

insert into artist (artiste, album, price) values ('Frank Sinatra','That\'s Life',8.20)

insert into artist (artiste, album, price) values ('Frank Sinatra','That''s Life',8.20)


Series Navigation<< MySQL: Using user-defined variables
MySQL: Handling null value >>

Leave a comment

Leave a Reply