Trevor Clissold Trevor Clissold - 1 month ago 8
MySQL Question

ANSWERED: In MySQL how do I edit multiple records with the same value at the same time?

I hope I've formatted this questions correctly, using 1&1 phpMyAdmin I need to update multiple records with the same value and want to see if there's an automated way of doing this rather than going through each record individually.

For example, I have about 200 rows to edit where league_id = 17 which currently have a value of 0 in the columns division_id and season_id and I want to make the division_id for each row 16 and the season_id for each row 10.

I can obviously go through each record and update it manually but that's going to be quite time consuming and I want to see if there is a way to update all 200 rows at the same time?

I hope this makes sense but forgive me if it's not formatted correctly and let me know if there's any other information needed to answer this.

Many Thanks

Answer

Update using one query, match the condition and execute update command like this:

update table_name set division_id =16, season_id =10 
where division_id = 0 and season_id  =0
Comments