Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I append a string to an existing field in MySQL?

People also ask

Which MySQL function can be used to add text to an existing value?

$sql = mysql_query("UPDATE ptb_messages SET subject = CONCAT(subject, 'newvalue') WHERE id='".


You need to use the CONCAT() function in MySQL for string concatenation:

UPDATE categories SET code = CONCAT(code, '_standard') WHERE id = 1;

Update image field to add full URL, ignoring null fields:

UPDATE test SET image = CONCAT('https://my-site.com/images/',image) WHERE image IS NOT NULL;