Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Joshua Berry
Hi Andrus, 2010/10/13 Andrus > 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 se

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Osvaldo Kussama
2010/10/13 Andrus : > 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

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Grzegorz Jaƛkiewicz
select regexp_replace(myval, E'(\\D)', '', 'g') from foo; for added speed, you might consider this: CREATE INDEX ON foo((regexp_replace(myval, E'(\\D)', '', 'g'))::bigint); which is also going to protect you against inserts where value doesn't contain any digits. and added benefit of index: gj=

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Josh Kupershmidt
2010/10/13 Andrus : > 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

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Jayadevan M
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,'-',''),' '

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Christian Ramseyer
On 10/13/2010 07:45 PM, Andrus wrote: 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? There are many options

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Rajesh Kumar Mallah
Dear Andrus, Quick & Dirty Soln: SELECT * from table where regexp_replace( col , '[-\\s+]' , '' , 'g') ilike '%search_term%' ; note above sql will not use any index if you have to search 1s of rows use alternate approaches. regds Rajesh Kumar Mallah. 2010/10/13 Andrus : > CHAR(20) c

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Craig Ringer
On 14/10/10 01:45, Andrus wrote: > 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 exampl

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Darren Duncan
Andrus wrote: 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 retur

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Merlin Moncure
2010/10/13 Andrus : > 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

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Pavel Stehule
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 CRET

[GENERAL] How to search ignoring spaces and minus signs

2010-10-13 Thread Andrus
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 m