Re: LIKE with no wildcards problem

From: Ian Barwick <barwick(at)gmx(dot)net>
To: "John J(dot) Allison" <john(at)joss(dot)ucar(dot)edu>, pgsql-sql(at)postgresql(dot)org
Subject: Re: LIKE with no wildcards problem
Date: 2002-02-28 19:36:48
Message-ID: 200202281937.UAA10702@post.webmailer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thursday 28 February 2002 19:54, John J. Allison wrote:
> When doing a select with a LIKE in the where clause,
> I always get 0 rows if I do not use a wildcard [_%].
> LIKE should act like = in this case (and the docs say so).
> A select without a from correctly returns 't'.
> I am using PostgreSQL 7.1.3 on Solaris.
> What am I missing?
>
> Thanks,
>
> John Allison
> john(at)joss(dot)ucar(dot)edu
>
>
> catalog^> create table foo ( bar char(8) )
> CREATE
>
> catalog^> insert into foo values ( 'abc' )
> INSERT 38413 1
>
> catalog^> insert into foo values ( '2.20' )
> INSERT 38414 1
>
> catalog^> select * from foo
> bar
> ----------
> abc
> 2.20
> (2 rows)

How about:

catalog^> SELECT bar, length(bar) from foo;

bar | length
----------+--------
abc | 8
2.20 | 8
(2 rows)

The CHARACTER type is always padded to the maximum length, viz:

http://www.postgresql.org/idocs/index.php?datatype-character.html

Ian Barwick

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 2002-02-28 19:46:32 Re: LIKE with no wildcards problem
Previous Message Josh Berkus 2002-02-28 19:28:37 Re: LIKE with no wildcards problem