'MySQL script to update the Account status based on the account number provided in an Excel file

I have a table in the MySQL database that contains account number and their status. Due to some reason, some of the account's status is changed from Active to Inactive.

Now I have a list of accounts whose status needs to change back to Active status based on the account number provided in an Excel file.

What will be the MySQL script to update the status of the account number to Active status based on the account numbers provided in the Excel file and what will be the approach to it.



Solution 1:[1]

First: in excel use textjoin formula example: =TEXTJOIN(",",false,B2:B40) on the numbers (if your MySql uses varchar you will need to use "','" instead of "," in the first argument)

Then copy that cell and paste it into your MySql which should be something like update table set status = 'Active' where account_no in ( <paste excel formula result here> ) I don't know your table or column names, so you need to adjust accordingly. Also you may need to split up if there are many accounts as an excel cell can only contain 32000 characters.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tnavidi