RE: [GENERAL] Problems with operator '%' within a select

From: "Sean Carmody" <sean(at)categoricalsolutions(dot)com(dot)au>
To: "Gabriel Fernandez" <gabi(at)unica(dot)edu>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: RE: [GENERAL] Problems with operator '%' within a select
Date: 2000-01-19 22:34:45
Message-ID: 001301bf62cd$62b4d860$0301a8c0@categoricalsolutions.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gabriel Fernandez wrote:

[Snip]

> I've just had some problems using the operator '%' within a select.
> This is an example:
>
> "select codigo from codis where codigo like '%3'"
>
> And i've found that all the rows which contains more than one three
> won't be selected.
> (For example: values 'a34ree3', '34fg3')
>
> It seems as if you put only one character with '%' it will select only
> the rows wich contain only one time this character.

[Snip]

On the face of it, it looks as though the problem you were having was as a
result of the % acting in a very minimal fashion, matching the first
'xxxx3' and then failing because the 3 it matched was not the end of the
string. Having said that, that's not how I would expect % to behave, and in
fact I can't seem to reproduce your problem. On release 6.5.2, I had the
following results:

test=> select str from test;
str
-----
abc3
a3bc3
a3bc2
a3bcx
a4bcx
(5 rows)

test=> select str from test where str like '%3';
str
-----
abc3
a3bc3
(2 rows)

What release are you using? Either there's a bug in the version you're
using, or there's something else going on.

Sean.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ed Loehr 2000-01-19 22:45:02 Re: [GENERAL] Creating Triggers
Previous Message Sarah Officer 2000-01-19 22:00:25 Creating Triggers