On 13 Aug 2003 at 16:17, Rob wrote:

> ID    |       Name
> ================
> 1     |       Author\'s
> 
> As you can see, the name value has been escaped.  Now, the question
> is, how do you match on a value that has escaped charaters?  I've
> tried the following
> 
> SELECT * FROM table WHERE Name = 'Author\'s'

The sequence "\'" in a MySQL string means an apostrophe.  What you 
want is a backslash followed by an apostrophe, so you need to put in 
two backslashes before it to represent a backslash:

  SELECT * FROM table WHERE Name = 'Author\\\'s';

Things are a bit more complicated with LIKE, because you want two 
backslashes in the string you give to LIKE, which means you need to 
start with four backslashes (there's an extra level of escaping):

  SELECT * FROM table WHERE Name LIKE 'Author\\\\\'s';

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to