"Savita" <savita.halli@gmail.com> wrote:
> PostgreSQL version: 8.3.5
> I have a table with id as primary key.
> When I ran query to get the ids which ends with B1
> select id from table where id like '%B1'
> does not return me any rows.
You might want to check all the bug fixes listed in the 8.3 bug fix
releases since the 2008 version you're running:
http://www.postgresql.org/docs/8.3/static/release.html
Then consider an in-place upgrade:
http://www.postgresql.org/support/versioning
and see if the problem is still there. It doesn't exist on the more
current releases I'm running. For example:
test=# create table t (id text not null primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"t_pkey" for table "t"
CREATE TABLE
test=# insert into t values ('AB1'),('AB2'),('AB3'),('AB4');
INSERT 0 4
test=# select id from t;
id
-----
AB1
AB2
AB3
AB4
(4 rows)
test=# select id from t where id like 'A%';
id
-----
AB1
AB2
AB3
AB4
(4 rows)
test=# select id from t where id like '%B1';
id
-----
AB1
(1 row)
If you apply the available 8.3 bug fixes and still see the problem,
creating a self-contained test case like the above will allow others
to better help you.
-Kevin