X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 58F5D563CD for ; Mon, 14 Mar 2005 08:16:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20646-10 for ; Mon, 14 Mar 2005 08:16:07 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id A25AC563C5 for ; Mon, 14 Mar 2005 08:16:06 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) id 1DAkiA-000HG5-4C; Mon, 14 Mar 2005 08:14:02 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 6B03C164E9; Mon, 14 Mar 2005 08:16:06 +0000 (GMT) Message-ID: <42354847.9070403@archonet.com> Date: Mon, 14 Mar 2005 08:16:07 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Her Goo Cc: pgsql-sql@postgresql.org Subject: Re: sql: "LIKE" problem References: In-Reply-To: Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/188 X-Sequence-Number: 20667 Her Goo wrote: > I am using "postgresql-7.3.2-1" now! > > I met a problem when using "LIKE" in "WHERE" clause. > For example, a table named "t_test", and its data looks like below: > > # SELECT * FROM t_test; > id | c_name > ----+-------- > 1 | abc\ > 2 | abc\de > (2 rows) > # SELECT * FROM t_test WHERE c_name LIKE 'abc\d%'; > id | c_name > ----+-------- > (0 rows) > > I don't know why the result is "0 rows"(why not is "1 rows"), > And I have trid "LIKE 'abc\\d%'", the result is also "0 rows". You'll need to escape the backslash twice. Once for the SQL-level parsing and once for the LIKE pattern-matching itself. SELECT * FROM t_test WHERE c_name LIKE 'abc\\\\d%'; -- Richard Huxton Archonet Ltd