0

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?

2
  • 2
    What is the function of the HTML here? I don't understand. If you are just using HTML for presentation in the question, don't put it in a snippet. Commented Sep 24, 2015 at 8:06
  • 1
    Storing comma-separated values in a database is most often a sign for a bad database design. As long as its just a string for you and you are not interested in its substrings, fine. But once you don't treat this as a mere thing but do string manipulations on it (which is exactly what you are doing here!) it is very likely you chose a bad design. Commented Sep 24, 2015 at 8:35

1 Answer 1

2

Use this update query

update YourTableName set subscriptions=concat(subscriptions,',tablets,keyboards') 
where id='22'
Sign up to request clarification or add additional context in comments.

1 Comment

Correct; it is that simple. Strange that the OP didn't find this solution themselves.

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.