简体   繁体   中英

Adding a multiple values to single column in mysql

in my project a table in mysql database contains two columns one is "UserId"(Primary Key) and other is "Merchants". For example user_A has merchants a,b,c. Now how can i add or delete a merchant for the user_A ?

You should normalise your data structure a have a separate table for users' merchants with user id and merchant as 2 columns. The 3 merchants in the above example will be 3 records in this table. You can easily delete a merchant from this table using a delete statement.

You probably will need another table for merchant details as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM