14

I am having the table with the following structure

      ----------------------------
       id                  content
      ---------------------------
        1                   abc
        2                   bca
      ---------------------------

I want to append the character 'd' with the field 'content' ... So i want the table structure as follows

       ----------------------------
       id                  content
      ---------------------------
        1                   abcd
        2                   bca
      ---------------------------

How can i do this..

3

2 Answers 2

37

If you want update the column from the Table then use below Query

update table1 set content = concat(content,'d');

If you want to select the column concatenation with 'd; the use below Query

select id, concat(content,'d') as content from table1;

Refer :

http://sqlfiddle.com/#!2/099c8/1

Sign up to request clarification or add additional context in comments.

Comments

17

You can use the CONCAT, like so

SELECT 
  id,
  CONCAT(content, 'd') content
FROM tablename;

You can also specify a WHERE clause to determine which rows to update. Something like:

SELECT 
  id,
  CONCAT(content, 'd') content
FROM tablename
WHERE id = 1;

2 Comments

+1 for quick answer. But this will add d to that specific column in all row and OP doesn't mentioned this
@diEcho I updated my answer. But the question is lack more information about what exactly the OP is trying to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.