且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL在表的整个字段中添加前缀

更新时间:2023-12-01 10:53:16

使用CONCAT()(

Basically I just decided to switch my primary ID to a "source" field, as I will be importing stuff from multiple sources. Now I'd like to make it clear where things come from, as such I'd like to add a prefix to it, as to be portalname:formerID. I've tried

UPDATE pics SET source='nk:'+source WHERE 1=1
UPDATE pics SET source='nk:'+source WHERE faces > 0 (matches all records)

but every time phpMyAdmin returns 0 row(s) affected. ( Query took 0.0056 sec )

Any idea?

Use CONCAT() ( http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat ) to concatinate strings, not "+".