Shahulktm
Shahulktm

Reputation: 299

MySQL query for adding one or more elements to comma separated string list

I have MySQL table with column name 'subscriptions'. It contains some comma separated values.

Id  Subscription
22  mobiles,watches,Tv,laptops

I need to add tablets, keyboards to this subscription field ie, my table should look like this

Id  Subscription
22  mobiles,watches,Tv,laptops,tablets,keyboards

Any special MySQL queries for this?

Upvotes: 0

Views: 1178

Answers (1)

ManiMuthuPandi
ManiMuthuPandi

Reputation: 1604

Use this update query

update YourTableName set subscriptions=concat(subscriptions,',tablets,keyboards') 
where id='22'

Upvotes: 2

Related Questions