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

2008-11-11 Thread Richard Huxton
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 >>

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

2008-11-11 Thread Dmitry Teslenko
On Mon, Nov 10, 2008 at 18:14, Richard Huxton <[EMAIL PROTECTED]> wrote: > Dmitry Teslenko wrote: >> Hello! >> There's table: >> CREATE TABLE table1 ( >> field1 CHARACTER(10), >> ... >> ); >> >> Then there's record: INSERT INTO table1(field1, ..) VALUES ('111', ...); >> >> Then I query

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

2008-11-10 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Dmitry Teslenko wrote: >> When is LIKE no records matches query, when is = >> my record matches query. Why? And Does this behavior varies from >> PostgreSQL 7.4 to 8.1? > You're comparing a 3-character value '111' of type text to a > 10-character one

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

2008-11-10 Thread Richard Huxton
Dmitry Teslenko wrote: > Hello! > There's table: > CREATE TABLE table1 ( > field1 CHARACTER(10), > ... > ); > > Then there's record: INSERT INTO table1(field1, ..) VALUES ('111', ...); > > Then I query it: > SELECT * FROM table1 WHERE field1 '111'; > > When is LIKE no records match

[GENERAL] LIKE, "=" and fixed-width character fields

2008-11-10 Thread Dmitry Teslenko
Hello! There's table: CREATE TABLE table1 ( field1 CHARACTER(10), ... ); Then there's record: INSERT INTO table1(field1, ..) VALUES ('111', ...); Then I query it: SELECT * FROM table1 WHERE field1 '111'; When is LIKE no records matches query, when is = my record matches query.