Search Postgresql Archives

Re: LIKE, "=" and fixed-width character fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux