On 2009-11-13, Lynn Manhart <ManhartL@mstarmetro.net> wrote:
> I have an application where I need to "select" based on whether or not a
> "text" column value contains a given substring. I have tried the "position"
> function as follows, but it doesn't return anything:
>
> select * in customers where position ('sub_string' in 'text_column') > 0;
>
> Is there another way to do this?
ITYM:
select * FROM customers where position ('sub_string' in "text_column") > 0
perhaps using the like or ~ operators
select * FROM customers where "text_column" LIKE '%sub_string%";
select * FROM customers where "text_column" ~ 'sub_string";
these operatours apply some magic to the contents of substring so for
useful results care must be taken when preparing it.
> 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.
depends on the locale setting, "C" will get you ordering by unicode
code point so 'A' < 'Z' < 'a' < 'z' < 'À' < 'Ý'
"EN-US" should get you "dictionary" ordering
show lc_collate;