Jump to content

UPDATE with SELECT and GROUP_CONCAT


tim79

Recommended Posts

Hi All, its been about 10 years since I messed about with Mysql and I'm already stuck trying to move a db to another crm!

You have an error in your SQL syntax;  near 'GROUP BY `csvimport`.groupid' at line 4

UPDATE customers
    inner join csvimport ON (customers.`id` = csvimport.`groupid`)
    SET customers.`bigaddress` = GROUP_CONCAT( csvimport.`col1` SEPARATOR ', ')
GROUP BY `csvimport`.groupid;

Attached is a screenshot of the csvimport table the addresses are split into rows making use of groupid and lineid with the data in col1

The new customers table have a field with the address all as one field. so I need to get into the BigAddress field of the customers table "Company ONE Name,Company ONE Address Line1,Company ONE Address Line2,Company ONE Address Line3,Company ONE Address Postcode"

And the company table all we need to know is id,bigaddress

I hope that makes sense!?

Thanks.

Screenshot 2024-05-28 at 08.56.08.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...