I have a MySQL db with a list of people, including their address, which I want to return as one field in a query. It's split into address1, address2, address3, address4, post_code
and I want to do something like the following
SELECT CONCAT(`address1`, ' ', `address2`, ' ', `address3`, ' ', `address4`, ' ', `post_code`) AS `address` FROM `table`
So I'll end up with a full string of their address in address
which works fine but if some of the fields are empty then I'll end up with a lot of double spaces. How can I eliminate the extra spaces? Is there an easier way than doing an IF() on each field?