Tuesday, January 1, 2013

PostgreSQL: Replace multiple spaces with one

If you want to use a single query to replace multiple spaces with one on SQL Server, you can read the articles here http://www.sqlservercentral.com/articles/T-SQL/68378/
However, it's very simple in PostgreSQL by using Regular Expression
SELECT regexp_replace('This    sentence     contains             multiple                 spaces', '\s+', ' ', 'g');

Oracle Query