I have a lot of records in my database with excessive spaces:

```
to buy  books is  like to buy
bad   journalists  aren't taken   hostage
  for your   information  this isn't    what we do

```

Is there a way to, in (My)SQL
 - replace all spaces by just one
 - strip all whitespace from the beginning and end of the string?

Otherwise I could always do it in php, looking all records through

```
$cleaned = trim(preg_replace('/\s+/', ' ', $string));

```

But that would require much more time I imagine (I have millions of records)