I need to add the word βexampleβ to the end of the keywords text column.
keywords
If there is already text in the column, the added word will be separated by a space :
Column `keywords` = ''; Add word 'example' Result `keywords` = 'example'
BUT
Column `keywords` = 'Some text' Add word 'example' Result `keywords` = 'Some text example'
UPDATE table SET keyword=( CASE WHEN keyword='' THEN 'example' ELSE concat(keyword,' example') END );
to try
UPDATE table SET `keyword` = CONCAT_WS(' ','your text',`keyword`)
Reference
Here is another approach that some may prefer:
UPDATE `table` SET `keywords` = TRIM(CONCAT(`keywords`, ' ', 'example'))
This one will not leave a leading space if the field is empty.
select concat(keyword,' example') from tbl ;
Edition: To update, use below:
UPDATE table SET keyword = CASE keyword WHEN '' THEN 'example' ELSE concat(keyword,' example') END;
Try the following:
Select CONCAT (keywords, example) from myTable
try the following:
UPDATE table SET `keyword` = CONCAT(`keyword`, ' ', 'example')