You could sanitize your data. For instance with regexp_replace()
. Run in the database once:
UPDATE invoice
SET buyer = regexp_replace(buyer, '\s\s+', ' ', 'g')
WHERE buyer <> regexp_replace(buyer, '\s\s+', ' ', 'g');
And sanitize new inserts & updates likewise.
\s
.. class shorthand for "white space" (including tab or weird spaces).
The 4th parameter 'g'
is for "globally", needed to replace all instances, not just the first.