Reputation: 4144
Is there any way to remove all spaces using SQLite, kind of global trim()
, not using any scripting language? I'm trying to hash values from multiple columns to track any changes but that will require to remove spaces for columns with multiple strings.
So far I wasn't able to find any tip related to that topic.
Upvotes: 5
Views: 8218
Reputation: 544
if you mean remove extra spaces
trim(replace(replace(replace(mycolumn, ' ', '| '), ' |',''), '|',''))
Upvotes: 0
Reputation: 304434
SQLite has some built-in string functions, including trim().
select trim(mycolumn) from mytable;
If you're trying to delete all spaces, you can use replace().
select replace(mycolumn, ' ', '') from mytable;
If you are trying to combine several columns you can use this with the concatenate operator.
select trim(col1) || trim(col2) || trim(col3) from mytable;
Upvotes: 11