Re: How to search ignoring spaces and minus signs

From: Jayadevan M <Jayadevan(dot)Maymala(at)ibsplc(dot)com>
To: "Andrus" <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-general-owner(at)postgresql(dot)org
Subject: Re: How to search ignoring spaces and minus signs
Date: 2010-10-14 04:05:15
Message-ID: OFF08F996E.42E6842D-ON652577BC.00165473-652577BC.00167400@ibsplc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
>
> For example searching for code 12344 should return
> 12 3-44 as matching item.
>
> Andrus.
>
This will do?
postgres=# select name from myt;
name
------------
13-333-333
12 3-44
33 33 333
12345
(4 rows)

postgres=# select * from myt where translate(translate(name,'-',''),'
','') = '13333333';
name
------------
13-333-333
(1 row)

postgres=# select * from myt where translate(translate(name,'-',''),'
','') = '12344';
name
---------
12 3-44
(1 row)

Regards,
Jayadevan

DISCLAIMER:

"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Reuven M. Lerner 2010-10-14 04:31:17 Re: Passing refcursors between pl/pgsql functions
Previous Message Craig Ringer 2010-10-14 03:53:18 Re: How to search ignoring spaces and minus signs