I have a table that contains a bunch of addresses in cells marked with the address | town. I am trying to combine the full address into a common format "address, city".
Sometimes, in my database, I will have one of the location cells empty. So I do IFNULL in my concat line, but in the end I have a leading or trailing ",". I tried the "trim" function along with my concat, but sometimes I get hooked with ",".
This is how I wrote my request
SELECT TRIM (BOTH ',' FROM CONCAT (IFNULL (address, ''), ',', IFNULL (city, ''))) FROM locals
Any idea why I would have this behavior? Is there a better way to create my concat statement?
source share