Re: LIKE vs =

From: Dror Matalon <dror(at)zapatec(dot)com>
To: SF PostgreSQL Users <sfpug(at)postgresql(dot)org>
Subject: Re: LIKE vs =
Date: 2004-08-23 20:13:32
Message-ID: 20040823201332.GY42093@rlx11.zapatec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug


Works for me (unless I'm missing something):

create table foo (a text);
CREATE TABLE
zp1936=> insert into foo values ('??????');
INSERT 113654463 1
zp1936=> select * from foo where a = '??????';
a
--------
??????
(1 row)

zp1936=> select * from foo where a like '??????';
a
--------
??????
(1 row)

Dror

On Mon, Aug 23, 2004 at 10:39:38AM -0700, David Wheeler wrote:
> Hi All,
>
> I'm having some trouble with multibyte characters and LIKE. We've been
> using LIKE instead of = for string queries for a long time, as it gives
> us flexibility to use wildcards such as "%" when we need to and get the
> same results as with = by not using them. But I've just found that it
> sometimes doesn't work properly:
>
> bric=# select version();
> version
> ------------------------------------------------------------------------
> ---------------------------------
> PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2
> 20030222 (Red Hat Linux 3.2.2-5)
> (1 row)
>
> bric=# select * from keyword where name = '??????';
> id | name | screen_name | sort_name | active
> ------+--------+-------------+-----------+--------
> 1218 | ?????? | ?????? | ?????? | 1
> (1 row)
>
> bric=# select * from keyword where name LIKE '??????';
> id | name | screen_name | sort_name | active
> ----+------+-------------+-----------+--------
> (0 rows)
>
> Any idea why = works here and LIKE wouldn't?
>
> TIA,
>
> David

--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.fastbuzz.com
http://www.zapatec.com

In response to

  • LIKE vs = at 2004-08-23 17:39:38 from David Wheeler

Responses

Browse sfpug by date

  From Date Subject
Next Message Josh Berkus 2004-08-23 20:37:29 Re: LIKE vs =
Previous Message David Wheeler 2004-08-23 18:10:46 Re: LIKE vs =