Sahipsiz
Sahipsiz

Reputation: 105

Adding text to the contents of the column?

I want to add mark_ to the beginning of the data contained in the column SYSLOCE2.

How do I get this done automatically with query?

|---------------------|------------------|    |---------------------|------------------|
|          ID         |      SYSLOCE2    |    |          ID         |      SYSLOCE2    |
|---------------------|------------------|    |---------------------|------------------|
|          1          |       sample     |    |          1          |       mark_sample|
|---------------------|------------------|    |---------------------|------------------|
|          2          |       people     |    |          2          |       mark_people|
|---------------------|------------------| => |---------------------|------------------|
|          3          |       hello      |    |          3          |       mark_hello |
|---------------------|------------------|    |---------------------|------------------|
|          4          |       world      |    |          4          |       mark_world |
|---------------------|------------------|    |---------------------|------------------|

Upvotes: 0

Views: 35

Answers (2)

sticky bit
sticky bit

Reputation: 37472

Use concat() to concatenate strings.

UPDATE elbat
       SET sysloce2 = concat('mark_', sysloce2);

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269563

You can use update:

update t
    set sysloce2 = concat('mark_', sysloce2);

In the more recent versions of MySQL, you could use a computed column instead.

Upvotes: 2

Related Questions