如何将三列的行转换为SQL插入语句? [英] How can I convert rows with three columns into SQL insert statements?
问题描述
我有一个如下所示的电子表格:
I have a spreadsheet looking like this:
あう to meet
青 あお blue
青い あおい blue
有没有一种方法可以将这些列中的数据转换为三个SQL语句,然后可以将其用于将数据输入数据库中?我不太想问如何形成该语句,但是我想知道是否有一种方法可以将列中的数据放入脚本中?
Is there a way that I could convert the data in these columns into three SQL statements that I could then use to enter the data into a database? I am not so much concerned in asking how to form the statement but I would like to know if there's a way I can take data in columns and make it into a script?
如果我可以将其转换为:
If I could convert this into:
col1:青いcol2:あおいcol3:蓝色
col1: 青い col2: あおい col3: blue
我可以为正确的格式添加和修改
I could add and modify this for the correct format
INSERT INTO JLPT col1,col2,col3 VALUES ('青い', 'あおい', 'blue')
etc
推荐答案
使用公式
="('"&A1&"', '"&B1&"', '"&C1&"'), "
in column D and copy the formula down for all the rows. Then prepend
Insert into JPT (col1, col2, col3) values
,您已完成.最终结果将是这样的:
and your are done. The end result will be something like this:
当您从Excel复制数据时,别忘了删除最后一个逗号(并有选择地将其替换为分号).
这篇关于如何将三列的行转换为SQL插入语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!