Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 73DA06327CB for ; Wed, 28 Jul 2010 15:34:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 21781-09 for ; Wed, 28 Jul 2010 18:34:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6EC1C6322EA for ; Wed, 28 Jul 2010 15:34:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o6SIYKJP020370; Wed, 28 Jul 2010 14:34:20 -0400 (EDT) To: Wes James cc: pgsql-sql@postgresql.org Subject: Re: how to escape _ in select In-reply-to: References: Comments: In-reply-to Wes James message dated "Wed, 28 Jul 2010 11:35:18 -0600" Date: Wed, 28 Jul 2010 14:34:20 -0400 Message-ID: <20369.1280342060@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/112 X-Sequence-Number: 34425 Wes James writes: > I'm trying to do this: > select * from table where field::text ilike '%\_%'; > but it doesn't work. You need to double the backslash, because one level of backslash-escaping will be eaten by the string literal parser. In the above example, the actual string value seen by ILIKE is just %_%, so of course it doesn't do what you want. regards, tom lane