[CS-FSLUG] Moving things around in SQL

Timothy Butler tbutler at ofb.biz
Mon Jan 7 01:10:03 CST 2013

Thanks so much, Robert. I'm sorry for the slow response but I really appreciate the advice!


On Nov 19, 2012, at 11:14 AM, Robert Wohlfarth <rbwohlfarth at gmail.com> wrote:

> On Sat, Nov 17, 2012 at 10:55 PM, Timothy Butler <tbutler at ofb.biz> wrote:
> Hello, friends,
>         Let's say I have two columns in MySQL named body and extbody. Is there any easy way, entirely within a SQL query to take everything in extbody and append it to the existing body column for every row in the table? I've rethought the way I want to structure a MySQL table for a web app I've been working on and need to rapidly move the data around in four or five different installations, so doing so entirely in a self-contained query would make it a lot faster process...
> Do you mean something like this?
> UPDATE table SET body = CONCAT(COALESCE(body,''), COALESCE(extbody,''))
> If you want the extended text to start on the next line, it could be something like this:
> UPDATE table SET body = CONCAT_WS(CHAR(10), COALESCE(body,''), COALESCE(extbody,''))
> -- 
> Robert Wohlfarth
> _______________________________________________
> ChristianSource FSLUG mailing list
> Christiansource at ofb.biz
> http://cs.uninetsolutions.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ofb.biz/pipermail/christiansource_ofb.biz/attachments/20130107/848fd26a/attachment.htm>

More information about the Christiansource mailing list