List:General Discussion« Previous MessageNext Message »
From:Olaf Stein Date:February 4 2009 4:04pm
Subject:Re: like isn't behave as expected
View as plain text  


Because MySQL uses C escape syntax in strings (for example, ³\n² to
represent a newline character), you must double any ³\² that you use in LIKE
strings. For example, to search for ³\n², specify it as ³\\n². To
search for
³\², specify it as ³\\\\²; this is because the backslashes are
stripped once
by the parser and again when the pattern match is made, leaving a single
backslash to be matched against. (Exception: At the end of the pattern
string, backslash can be specified as ³\\². At the end of the string,
backslash stands for itself because there is nothing following to escape.)

On 2/4/09 10:49 AM, "Yariv Omer" <yarivo@stripped> wrote:

> Hi
> i have one row in the cpe_id column of the cpe_users table in my
> database with the value: "d\d".
> when i am doing:select cpe_id from cpe_users where cpe_id = 'd\\d' >> I
> got the one result.
> when i am doing:select cpe_id from cpe_users where cpe_id like 'd\\d' >>
> I don't get any result!
> why?
> also when i am doing: when i am doing:select cpe_id from cpe_users where
> cpe_id = 'd\\\\d' >> I do get the one result
> why?
> Thanks, Yariv

Olaf Stein
Battelle Center for Mathematical Medicine
Nationwide Children's Hospital, The Research Institute
700 Children's Drive
43205 Columbus, OH
phone: 1-614-355-5685
cell: 1-614-843-0432
email: olaf.stein@stripped

³I consider that the golden rule requires that if I like a program I must
share it with other people who like it.²
Richard M. Stallman

----------------------------------------- Confidentiality Notice:
The following mail message, including any attachments, is for the
sole use of the intended recipient(s) and may contain confidential
and privileged information. The recipient is responsible to
maintain the confidentiality of this information and to use the
information only for authorized purposes. If you are not the
intended recipient (or authorized to receive information for the
intended recipient), you are hereby notified that any review, use,
disclosure, distribution, copying, printing, or action taken in
reliance on the contents of this e-mail is strictly prohibited. If
you have received this communication in error, please notify us
immediately by reply e-mail and destroy all copies of the original
message. Thank you.
like isn't behave as expectedYariv Omer4 Feb
  • RE: like isn't behave as expectedJerry Schwartz4 Feb
  • Re: like isn't behave as expectedOlaf Stein4 Feb