Re: using position in where - Mailing list pgsql-novice

From John DeSoi
Subject Re: using position in where
Date
Msg-id 2B8A7A9C-EDBA-4BD6-9C3C-70E55F7970A2@pgedit.com
Whole thread Raw
In response to using position in where  ("Lynn Manhart" <ManhartL@mstarmetro.net>)
List pgsql-novice
On Nov 12, 2009, at 7:29 PM, Lynn Manhart wrote:

> select * in customers where position ('sub_string' in 'text_column')
> > 0;

If you really have single quotes around the name of your text column,
position is looking for your string in that literal text. It should
not have single quotes. If your column name is a reserved word or has
special characters you can double quote it.

I also think you want select * "FROM" not "IN", so

SELECT * FROM customers WHERE position('sub_string' in
customers_text_column) > 0;

> Another question - how are upper and lower case handled when using
> "order by"? In my experimenting, it seems to be doing a case
> insensitive compare, but the docs I've read seem to indicate
> otherwise.

It depends on the locale settings when the cluster was created. On US
systems, typically uppercase precedes lowercase. E.g. "Zip" is before
"apple" in an ascending sort.



John DeSoi, Ph.D.





pgsql-novice by date:

Previous
From: "Lynn Manhart"
Date:
Subject: using position in where
Next
From: Jasen Betts
Date:
Subject: Re: using position in where