当前位置: 动力学知识库 > 问答 > 编程问答 >

csv - MySql CONCAT add data to column beginning and end

问题描述:

I've succeed to add data to the beginning and the end of a column by using CONCAT, but would like to here if there is a smarter/faster command/way to do this.

JOB: I've got a csv dump from foreign domain which I have to modify to fit my website/DB. In the DB there is a column containing embed data for video player, but... the source CSV only have the http://domain.com/embed.php?video=5894372 why i have to add <iframe width="640" height="480" src=" and " frameborder="0" scrolling="no"></iframe> to the these in the mod-DB.

What I have done with succes

UPDATE `DB_name`.`table_name` SET embed = CONCAT(embed,'" frameborder="0" scrolling="no"></iframe>');

UPDATE `DB_name`.`table_name` SET embed = CONCAT('<iframe width="640" height="480" src="',embed);

DB column "embed" is varchar,255

Write your suggestion and why? I'm all ears

网友答案:

You can use a singole update

    UPDATE `DB_name`.`table_name` 
    SET embed = CONCAT('<iframe width="640" height="480" src="', 
                         embed ,
                '" frameborder="0" scrolling="no"></iframe>' );
分享给朋友:
您可能感兴趣的文章:
随机阅读: