i want update my row and concat my string but i have an error with thi开发者_开发技巧s query
UPDATE FILE SET NOMFIC ='supp_'+D_NOMFIC WHERE IdFile = 2
UPDATE FILE SET NOMFIC = CONCAT('supp_',NOMFIC) WHERE IdFile=2;
See the CONCAT()
function within the MySQL documentation here
CONCAT() basically takes as its parameters a list of strings to be concatenated together.
You can't concat with + in MySQL. Use CONCAT('supp_, D_NOMFIC)
, so it becomes UPDATE FILE SET NOMFIC = CONCAT('supp_, D_NOMFIC) WHERE IdFile = 2
For more info see: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat
You can concat quoted strings like this: SELECT 'a' 'b' 'c' FROM someTable
though.
Try this:
UPDATE FILE SET NOMFIC = CONCAT('supp_', D_NOMFIC) WHERE IdFile = 2
Use CONCAT
instead:
UPDATE FILE SET NOMFIC =CONCAT('supp_',D_NOMFIC) WHERE IdFile = '2'
Try this:
update table_name set column_name1=CONCAT(column_name2,'something');
精彩评论