June 25th, 2013

I have the unfortunate task for merging two distinctly different channels in ExpressionEngine into a new third channel. If it was only a few entries I would probably do it by hand, but there are hundreds of them. I tried AJW DataGrab, but the matrix field wasn't cooperating. Then I tried Solspace Importer, but the add-on got stuck in an infinite upgrade loop.

So I had to dig deep and write a few MySQL statements and ended up using a couple new commands. My favorite is GROUP_CONCAT, using it I was able to combine several matrix rows into one field. The only problem I had was the standalone query had a GROUP BY clause that worked fine, but when I added it to an UPDATE command I had to remove the GROUP BY in order for it to work. Weird, but not too bad.

My code is way to specific to be used as an example, but here's the MySQL docs. And this blog has a really basic example.