Skip to content
Advertisement

How do I add multiple values to a column in SQL which already has other rows filled

I’m trying to update this table (name: sports_club):

I’m trying to add values to just the sport_interest column of the existing records, I tried to do that by using:

But it did not work as it was trying to add it to new records which I don’t want to do. I’m using MySQL

Advertisement

Answer

You can do the updates manually like:

And so on…

But, if you have the id of the values that you need to update it is much easier.

You can create another table like:

You can use LOAD DATA to insert the data on the new table and then update using inner join, it is simpler and much faster.

I suggest reading https://www.mysqltutorial.org/mysql-basics/ or https://www.techonthenet.com/mysql/index.php this are much better than W3Schools

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement