Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL add prefix to field table-wide

Tags:

mysql

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?

like image 995
Robus Avatar asked Dec 17 '22 16:12

Robus


1 Answers

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

like image 127
Stefan H Singer Avatar answered Dec 19 '22 08:12

Stefan H Singer