开发者

MySQL add prefix to field table-wide

开发者 https://www.devze.com 2023-02-15 04:07 出处:网络
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

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 too开发者_Go百科k 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 "+".


you may try to omit the where clause altogether.

UPDATE pics SET source= concat('nk:',source )

or better yet, add a new column 'portal_name' and populate that seperately.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号