pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
sort order with < & > in varchar fields
2+ messages / 2 participants
[nested] [flat]

* sort order with < & > in varchar fields
@ 2001-01-17 13:39  Rolf Johansson <rojo@nocrew.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Rolf Johansson @ 2001-01-17 13:39 UTC (permalink / raw)
  To: pgsql-sql

It is possible to extract rows in a table using
SELECT name FROM table WHERE name >= 'Bergman'.

The problem I have is that I get names like "Berg, Paul"
with this query, and I don't want that.

Is there documentation on how >= and <= works with varchar
fields? Does pg count in the "," character or ignore it?
And so on...

Version is 7.0.1.

/Rolf



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: sort order with < & > in varchar fields
@ 2001-01-17 15:28  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Rolf Johansson <rojo@nocrew.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2001-01-17 15:28 UTC (permalink / raw)
  To: Rolf Johansson <rojo@nocrew.org>; +Cc: pgsql-sql

Rolf Johansson <rojo@nocrew.org> writes:
> Is there documentation on how >= and <= works with varchar
> fields? Does pg count in the "," character or ignore it?

That depends.  If you compiled with --enable-locale then it's
whatever strcoll() says for the locale you are running the
postmaster in.  If not, it's whatever strcmp() says, which is
normally plain ASCII collation order.

Note: beware of changing the postmaster's locale on the fly;
this can leave your indexes on textual columns out of order and
hence effectively corrupt.  You can fix that by dropping/rebuilding
such indexes, or with REINDEX.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-01-17 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-17 13:39 sort order with < & > in varchar fields Rolf Johansson <rojo@nocrew.org>
2001-01-17 15:28 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox