[Answer]-Combine strings from mysql tables without extra spaces

1👍

In MySQL, I think you are looking for concat_ws():

concat_ws(' ', nullif(namt, ''), nullif(namf, ''), nullif(naml, ''), nullif(nams, ''))

The nullif() turns the value to NULL if it is blank. concat_ws() ignores NULL values, so you won’t get duplicated spaces.

Leave a comment