RE: [GENERAL] Problems with operator '%' within a select - Mailing list pgsql-general

From Sean Carmody
Subject RE: [GENERAL] Problems with operator '%' within a select
Date
Msg-id 001301bf62cd$62b4d860$0301a8c0@categoricalsolutions.com.au
Whole thread Raw
In response to Problems with operator '%' within a select  (Gabriel Fernandez <gabi@unica.edu>)
List 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.



pgsql-general by date:

Previous
From: Sarah Officer
Date:
Subject: Creating Triggers
Next
From: Ed Loehr
Date:
Subject: Re: [GENERAL] Creating Triggers