On Wed, Aug 13, 2003 at 09:23:38AM -0500, Jay Blanchard wrote:
> [snip]
> 
> 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'
> 
> SELECT * FROM table WHERE Name LIKE 'Author\'s'
> SELECT * FROM table WHERE Name = '%Author\'s%'
> SELECT * FROM table WHERE Name = 'Author''s'
> SELECT * FROM table WHERE Name = "Author\'s"
> SELECT * FROM table WHERE Name = "Author's"
> [/snip]
> 
> The only one you didn't try....
> 
> SELECT * FROM table WHERE Name LIKE 'Author%'
> 

Or any of these, which are more specific:

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

You need to escape the \ because it is the escape character and you need
to escape the ' in the first case because it is a string terminator.


Regards,

Fred.

-- 
Fred van Engen                              XB Networks B.V.
email: [EMAIL PROTECTED]                Televisieweg 2
tel: +31 36 5462400                         1322 AC  Almere
fax: +31 36 5462424                         The Netherlands

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

Reply via email to