MySQL adds a prefix to the field for the entire table

Basically, I just decided to switch my main identifier in the "source" field, since I will import material from several sources. Now I would like to make it clear where this comes from, so I would like to add a prefix to it to be portalname:formerID . I 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 ) 0 row(s) affected. ( Query took 0.0056 sec )

Any idea?

+4
source share
2 answers

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

+6
source

you can generally skip the where clause.

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

or better yet, add a new column 'portal_name' and populate it separately.

+6
source

Source: https://habr.com/ru/post/1342697/


All Articles