-2

i want to add new variable without deleting old variable with using Update Set. i added example of my table and i wrote below the query. How can i do?

update ActionsProperties 
set PropertyValue = PropertyValue + ',x@x' 
where PropertyValue = 'y@y' and PropertyName = 'EmailTo'

When i see y@y mail addresses i want to add email: x@x

Kamil Gosciminski
  • 16,547
  • 8
  • 49
  • 72
Mnks
  • 9
  • 3
  • If you want to keep the old column value, you can create new column by altering the table and populate it with the new value in UPDATE statement. Right now what you're doing is concatenation. – Kamil Gosciminski Oct 03 '18 at 13:28
  • 1
    HeidiSQL is a SQL client application that can connect to different DBMS products. Which [DBMS](https://en.wikipedia.org/wiki/DBMS) are you using? "SQL" is just a query language, not the name of a specific database product (and your sample code is invalid standard SQL) Please add the tag for the database product you are using –  Oct 03 '18 at 13:41
  • Yes i can do but looking for an easier way. if i can not find i choose your option. @ Kamil Gosciminski – Mnks Oct 03 '18 at 13:43
  • You should have a separate table with the emails on a separate row for each property value. Then your code would be a simple `insert`. – Gordon Linoff Oct 03 '18 at 13:45

1 Answers1

0

Finally i found how can i do.

UPDATE ActionsProperties SET PropertyValue = CONCAT(PropertyValue, ',x@x') WHERE PropertyValue like '%y@y%' AND PropertyName = 'EmailTo'

Mnks
  • 9
  • 3