Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add some words to end of post in database

Tags:

mysql

I have table named Posts

I want to add some words to the end of this all posts in the table.

If I wanted to replace a word in my all posts I would use this query:

UPDATE posts
SET post_content = Replace(post_content, 'old_word', 'new_word')

but I want to add words to the end of my posts, not replace

Note: I want to do this in SQL query, without PHP

like image 701
Nour Eb Avatar asked Nov 29 '25 00:11

Nour Eb


2 Answers

It's similar to your example with REPLACE() but you would use CONCAT(). http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat

UPDATE posts SET post_content=CONCAT(post_content, ' Text you want to append.');
like image 54
Trott Avatar answered Dec 02 '25 03:12

Trott


Sounds like you want to use MySql "concat()":

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

like image 32
paulsm4 Avatar answered Dec 02 '25 03:12

paulsm4