之前的示例:

column x
yummy grains
blah blah
foobar 1
sugar daddy
foobar 2
fiber one

我想要的是:
column x
yummy grains
blah blah
gooey foobar 1
sugar daddy
gooey foobar 2
fiber one

最佳答案

UPDATE `yourtable`
   SET `column x`=CONCAT('gooey ',`column x`)
   WHERE `column x` LIKE '%foobar%';

请注意,这是一个查询(最后一个;)。
详细(不按语法上正确的顺序):
UPDATE yourtable-对于表中的行yourtable
WHERE column x-对于那些行,在列column x中。。。
LIKE '%foobar%'-…字符串中的某个地方(note the wildcards at both ends
foobar-将行的SET column x=设置为以下值:
column x-将文本字符串“CONCAT('gooey ',column x)”与gooey中的任何字符串连接(相加)。

09-10 07:47
查看更多