Skip site navigation (1) Skip section navigation (2)

Re: LIKE vs =

From: David Fetter <david(at)fetter(dot)org>
To: SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Re: LIKE vs =
Date: 2004-08-23 17:46:20
Message-ID: 20040823174620.GA8144@fetter.org (view raw or flat)
Thread:
Lists: sfpug
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?

Does LIKE when you stick wildcards on the front & back of the
expression?

SELECT * FROM keyword WHERE name LIKE '%ºÏÇÑÀÇ%';

Cheers,
D
-- 
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

In response to

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

Responses

sfpug by date

Next:From: David WheelerDate: 2004-08-23 17:57:09
Subject: Re: LIKE vs =
Previous:From: Josh BerkusDate: 2004-08-23 17:42:17
Subject: Re: LIKE vs =

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group