Re: LIKE, "=" and fixed-width character fields - Mailing list pgsql-general

From Richard Huxton
Subject Re: LIKE, "=" and fixed-width character fields
Date
Msg-id 49194083.4090404@archonet.com
Whole thread Raw
In response to Re: LIKE, "=" and fixed-width character fields  ("Dmitry Teslenko" <dteslenko@gmail.com>)
List pgsql-general
Dmitry Teslenko wrote:
>> richardh=> SELECT * FROM chartbl WHERE c LIKE '111';
>>  c
>> ---
>> (0 rows)
>>
>> richardh=> SELECT * FROM chartbl WHERE c LIKE '111       ';
>>     c
>> ------------
>>  111
>> (1 row)
>>
>> richardh=> SELECT * FROM chartbl WHERE c LIKE '111%';
>>     c
>> ------------
>>  111
>> (1 row)
>>
>
> '111%' would also match '1111' and '111anything', wouldn't it?

Yes.

I'm guessing what you actually want is varchar(10) rather than char(10)
as a type.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Next
From: Richard Huxton
Date:
Subject: Re: Question about weird construct