如何使用sql update在mysql中编辑多个记录

时间:2012-10-21 03:45:41

标签: mysql sql insert sql-update record

版本MySQL:5.5.28 phpMyAdmin - 2.11.11.3

我有多个类型的记录:name_test /,name_test / etc,name_test / etc / etc name_test / etc / etc / etc / etc我希望它们像Top / name_test /,Top / name_test / etc, Top / name_test / etc / etc /,Top / name_test / etc / etc / etc / etc.

其中90%已经更改,因此我们只需要选择那些以“name_test /”开头的记录 问题是一个问题有点复杂,我你必须改变一些400万的filds。

**table exemple1**

**column1**             **column2**                 **column3**
name_test1              name_test2/etc              name_test3
Top/etc/etc/            Top/name_test2/etc/etc/     name_test/etc/etc/
name_test               Top/name_test/etc/
name_test               #name_test/etc/etc/etc/#
name_test               #name_test/etc/etc/#
name_test2              #name_test/etc/#
name_test5              #name_test/#
name_test/etc

我还有其他类似这样的语言表:

**table exemple2**

**column1**             **column2**                 **column3**
name_test1              italian:name_test2/etc              name_test3
Top/etc/etc/            english:Top/name_test2/etc/etc/     name_test/etc/etc/
name_test               Bulgarian:Top/name_test/etc/
name_test               Danish:#name_test/etc/etc/etc/#
name_test               Korean:#name_test/etc/etc/#
name_test2              Russian:#name_test/etc/#
name_test5              etc:#name_test/#
name_test/etc

注意:只有#filds#必须在示例中修改

其他记录开始,否则不会被修改 任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:2)

这应该适合你:

UPDATE table
SET column2 = concat('Top/', column2)
WHERE column2 LIKE 'name_test/%'