Received: from server (client-sp03-85.speedex.net [208.33.90.85]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f2TH7pK54465 for ; Thu, 29 Mar 2001 12:07:51 -0500 (EST) (envelope-from will@serensoft.com) Received: from will by server with local (Exim 3.12 #1 (Debian)) id 14iftm-0006eP-00 for ; Thu, 29 Mar 2001 11:07:50 -0600 Date: Thu, 29 Mar 2001 11:07:50 -0600 From: will trillich To: pgsql-general@postgresql.org Subject: Re: inconsistent functionality with LIKE operator Message-ID: <20010329110750.B25154@mail.serensoft.com> Mail-Followup-To: pgsql-general@postgresql.org References: <3AC2F17A.BFC50830@commandprompt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3AC2F17A.BFC50830@commandprompt.com>; from pma@commandprompt.com on Thu, Mar 29, 2001 at 08:25:30AM +0000 X-Archive-Number: 200103/1369 X-Sequence-Number: 6934 On Thu, Mar 29, 2001 at 08:25:30AM +0000, Phuong Ma wrote: > I'm using PostgreSQL version 7.1, and I'm having trouble with the LIKE > statement. How would I find the value "a\bc"? I tried using the > backslash to escape it: LIKE 'a\\b%'; > > If I specify: LIKE 'a\\bc', then it works, but if I wanted it to look > for consecetive characters after the c, using the %, then it returns > other values besides what I'm looking for. > > I also have the same problem with percent (%). I have a test string > with the value "ab%c", and I want to look for that using LIKE. I tried: > LIKE 'ab\%c', LIKE 'ab%%', and LIKE 'ab\%_', but these statements not > only returned what I was looking for, but also other values: > "abc","ABC", and "Abc". with LIKE, '%' means "anything" just as /.*/ does in a perl regex; and '_' means "any character" just as /./ does in perl. by default. you can change the escape char, tho -- http://google.com/search?as_q=like+select+escape&as_sitesearch=postgresql.org -- does a brain cell think? will@serensoft.com http://sourceforge.net/projects/newbiedoc -- we need your brain! http://www.dontUthink.com/ -- your brain needs us!