How can I convert rows with three columns into SQL

2019-09-05 16:00发布

I have a spreadsheet looking like this:

    あう  to meet
青   あお  blue
青い  あおい blue

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: blue

I could add and modify this for the correct format

INSERT INTO JLPT col1,col2,col3 VALUES ('青い', 'あおい', 'blue')
etc

标签: excel
1条回答
仙女界的扛把子
2楼-- · 2019-09-05 16:27

Use the formula

="('"&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:

enter image description here

Just don't forget to delete the last comma (and optionally exchange it for a semicolon) when you copy over the data from Excel.

查看更多
登录 后发表回答