When I put Excel data into the table in Mysql...

Asked 2 years ago, Updated 2 years ago, 46 views

When putting Excel data in the Mysql table

"LOAD DATA INFILE 'File Name' INTO TABLE Table Name"

As far as I know, you put it in this query, not all the Excel data in the table like that

Can't we just span some columns of accelerator data into the table?

For example, the column of Excel data is

[Separated school name, grade class number] It's organized like this.

In the Mysql table, [School Year Number]

What should I do when I want to insert just this data? <

database mysql

2022-09-21 18:17

1 Answers

Try the temporary table.

CREATE TEMPORARY TABLE TEMPORARY TABLE LIKE

If you do this as above, create a temporary table in the same structure as Table to actually save. (Same case)

If the structure is different, create the TABLE yourself, but add TEMPORARY.

CREATE TEMPORARY TABLE TEMPORARY TABLE (separated... school..., name...);

Next, load the data into the temporary table that you created.

LOAD DATA INFILE 'File Name'
    INTO TABLE TEMPORARY TABLE;

You can now query the data you need from the temporary table and add the data to the table you want to actually save.

INSERT INTO actual table to be saved (school, grade, number) SELECT school, grade, number FROM temporary table;

You can DROP the temporary table afterwards.

DROP TEMPORARY TABLE Temporary Table;

Note: http://www.w3schools.com/sql/sql_insert_into_select.asp


2022-09-21 18:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.