Reputation: 31
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
Upvotes: 3
Views: 116
Reputation: 121881
Sounds like you want to use MySql "concat()":
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
Upvotes: 2
Reputation: 70183
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.');
Upvotes: 3