P
P
Puma Thailand2012-03-02 16:11:25
MySQL
Puma Thailand, 2012-03-02 16:11:25

mysql. How to add one more value to the set type field for all rows in the table?

For example, there is a notify field of the set type; it has a choice in the form: email, sms, phone, post.
Each user himself chose how to notify himself, I want to add email notifications to everyone.
You can simply iterate through all the values ​​in the php script and add those who do not have it with updating each line via update.
Is it possible to do the same through one request and not kill other selected notification methods from the user.
That is, if the user had sms, phone selected, then it should become sms, phone, email

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sl_bug, 2012-03-02
@opium

UPDATE table SET notify = CONCAT_WS(',', myset, 'phone')
not?

S
startsevdenis, 2012-03-02
@startsevdenis

UPDATE tablename SET notify="email" WHERE notify=""

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question