I need to concatenate the address fields (zip,city,countryName, streetAddress) of my table. This is the query i wrote,
SELECT id,concat_ws(' ',address1,zip,city,(select countryName from country where countryCode = User.countryCode)) FROM User
And it provides me 28 Avenue Pasteur 14390 Cabourg France which should actually be, 27 Avenue Pasteur, 14390 Cabourg, France (with commas separated)
How can i do achieve this?
Update
when used SELECT id,concat_ws(',',address1,zip,city,(select countryName from country where countryCode = User.countryCode)) FROM User
it gives 27 Avenue Pasteur, 14390, Cabourg, France
but not 27 Avenue Pasteur, 14390 Cabourg, France (no comman in between 14390 Cabourg)
', 'instead of' ', if you want comma separators.