From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Andrus <kobruleht2(at)hot(dot)ee> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to search ignoring spaces and minus signs |
Date: | 2010-10-13 20:53:04 |
Message-ID: | AANLkTim-T6hv0AP4map1C1PidPMXTWKiBiTx7eomTWPf@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
you can use a own function
CREATE OR REPLACE FUNCTION clean_some(text)
RETURNS text AS $$
SELECT replace(replace($1, ' ',''),'-','')
$$ LANGUAGE sql;
then you can do query with where clause
WHERE clean_some(colum) = clean_some('userinput');
you can enhance it with functional index
CRETE INDEX xx ON your_table((clean_some(column));
Regards
Pavel Stehule
2010/10/13 Andrus <kobruleht2(at)hot(dot)ee>:
> CHAR(20) columns in 8.4 database may contains spaces and - signs like
>
> 13-333-333
> 12 3-44
> 33 33 333
> 12345
>
> User enters code to search without spaces and - signs, like 12344
> How to search for product code ignoring spaces and - signs?
>
> For example searching for code 12344 should return
> 12 3-44 as matching item.
>
> Andrus.
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2010-10-13 20:58:54 | Re: How to search ignoring spaces and minus signs |
Previous Message | Karsten Hilbert | 2010-10-13 19:26:41 | Re: Internationalisation of database content (text columns) |