Beluga Posted January 11, 2014 Share Posted January 11, 2014 (edited) How might I be able to concatenate all the addresses of a single customer into one field? How should this be modified: SELECT CONCAT_WS(' ', g.lastname, g.firstname) AS Customer, g.id_customer AS customerID, CONCAT_WS(' ', ad.address1, ad.address2, 'City:', ad.postcode, ad.city, ad.other, 'Phone:', ad.phone, 'Mobile:', ad.phone_mobile) AS Addresses, gl.name AS group_name, g.email FROM ps_customer g LEFT JOIN ps_address ad ON (g.id_customer = ad.id_customer) LEFT JOIN ps_group_lang gl ON (g.id_default_group = gl.id_group) AND gl.name LIKE 'club%' Edited January 13, 2014 by Beluga (see edit history) Link to comment Share on other sites More sharing options...
Beluga Posted January 13, 2014 Author Share Posted January 13, 2014 Here's the correct way: SELECT CONCAT_WS(' ', g.lastname, g.firstname) AS Customer, g.id_customer AS customerID, GROUP_CONCAT(CONCAT_WS(' ', ad.address1, ad.address2, 'City:', ad.postcode, ad.city, ad.other, 'Phone:', ad.phone, 'Mobile:', ad.phone_mobile)) AS Addresses, gl.name AS group_name, g.email FROM ps_customer g LEFT JOIN ps_address ad ON (g.id_customer = ad.id_customer) LEFT JOIN ps_group_lang gl ON (g.id_default_group = gl.id_group) AND gl.name LIKE 'piiri%' GROUP BY g.id_customer Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now