简体   繁体   English

如何通过csv文件更新sql表的仅一列

[英]How to update only one column of sql table by csv file

I have a csv file containg some data. 我有一个包含一些数据的csv文件。 And in my Sql Database I have a table with multiple column name. 在我的Sql数据库中,我有一个带有多个列名的表。 Now I want to update only one column by csv file. 现在,我只想通过csv文件更新一列。 Thanks 谢谢

You can try like this: 您可以这样尝试:

-Import the csv file to a temp table
-Update your main table by joining with a temp table.

As stated by the MySQL Documentation you can do this MySQL文档所述,您可以执行此操作

LOAD DATA INFILE 'mycsvdata.csv'
INTO TABLE mytable
( @csvfield1, @csvfield2 )
SET myTabField = @csvfield2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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