user1569552
user1569552

Reputation: 1

MySQL - Adding a string to a text column

I'm trying to add a text string to certain columns. This is a query I've tried, it failed miserably though, but it explains what I want to do.

SET @NAME = (Select name from item_template where itemset = 801);
SET @NEWNAME = ('|cFFFF0000'+@NAME);
Update item_template set name = @NEWNAME where itemset = 801;

Thanks in advance! :)

Upvotes: 0

Views: 87

Answers (3)

jcho360
jcho360

Reputation: 3759

SET @NEWNAME = ('|cFFFF0000'+@NAME);

use concat

SET @NEWNAME := CONCAT('|cFFFF0000',@NAME);

Upvotes: 0

juergen d
juergen d

Reputation: 204746

try

Update item_template
set name = (select * from (select concat('|cFFFF0000', name) 
                           from item_template
                           where itemset = 801) x
           ) 
where itemset = 801;

or even shorter

Update item_template
set name = concat('|cFFFF0000', name) 
where itemset = 801;

Upvotes: 0

Borgtex
Borgtex

Reputation: 3245

Why not just

update item_template set name = concat('|cFFFF0000',name) where itemset = 801;

Upvotes: 1

Related Questions