如何使用Excel更新MySQL数据库中的列 [英] How to update a column in mySQL database with Excel
问题描述
我有一张桌子,大约有一张. 10,000条客户记录. 表结构如下:
I have a table which has approx. 10,000 client records. The table structure look like this:
客户ID | 名字 | 姓氏 | 电话号码
ClientID | FirstName | LastName | PhoneNumber
我正在尝试使用更新的Excel文件更新 PhoneNumber 列, 其中只有两列 ClientID | 电话号码
I am trying to update the PhoneNumber column with a updated Excel file, which only has two columns, ClientID | PhoneNumber
我的cpanel已安装phpmyadmin,但是如何将excel文件导入数据库并仅基于 ClientID 更新 PhoneNumber ?
My cpanel has phpmyadmin installed, but how do I import the excel file into the database and only update the PhoneNumber based on ClientID?
谢谢!
推荐答案
我不知道是否可行,但是您可以轻松地使用excel电子表格生成一系列MySQL命令来更新电话号码.如果ID为A列,电话号码为B列,则该功能将为:
I don't know if that's possible, but you can easily use the excel spreadsheet to generate a series of MySQL commands to update the phone number. If the ID is column A and the phone number is column B, then the function would just be:
concatenate("update yourTableName set phonenumber = '", A1, "' where ID = ", B1, ";")
然后填写并复制生成的命令到PHPMyAdmin的"SQL"选项卡中.
Then fill down and copy the resulting commands into PHPMyAdmin's SQL tab.
这篇关于如何使用Excel更新MySQL数据库中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!