MySQL在表的整个字段中添加前缀 [英] MySQL add prefix to field table-wide

查看:534
本文介绍了MySQL在表的整个字段中添加前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我刚决定将我的主要ID切换到源"字段,因为我将从多个源中导入内容.现在,我想弄清楚事情的来历,例如,我想给它添加一个前缀,例如portalname:formerID.我已经尝试过

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

但是每次phpMyAdmin返回0 row(s) affected. ( Query took 0.0056 sec )

有什么主意吗?

解决方案

使用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 "+".

这篇关于MySQL在表的整个字段中添加前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆