What\'s the best way to run a query so that spaces in the fields are ignored? For example, the following queries:
SELECT * FROM mytable WHERE username = \"Jo
We often want to search for text, regardless of the number of spaces, white space and letters.
Just trim , lower case , and replace all multipe Non-word characters for one space.
SELECT regexp_replace(trim(lower('Here is a long text , with many white spaces AND different character sensitive')),'\W+',' ','g') t
return :here is a long text with many white spaces and different character sensitive
Here is the use for search. Only the order of words is important, nothing more.And this is beautiful.
select * from (
SELECT regexp_replace(trim(lower('Here is a long text , with many white spaces AND different character sensitive')),'\W+',' ','g') t
) as o
where t= regexp_replace(trim(lower('Here is a LonG TEXT , with mANY white ^ spaces AND different character sensiTive')),'\W+',' ','g')
return:here is a long text with many white spaces and different character sensitive
Garbage in data and junk in the query, but it still finds it right.