Import Excel Data to MySQL database

Source: Internet
Author: User
Method 1: 1. in the last column of the data to be imported, write an Excel Formula (in this example, it is the cell under "SQL", "SQL" is not necessary, just for convenience ). = Concatenate ("insert into employee (name, birthday, email, Hober) values ('", RC [-4], "', '", RC [-3], "','", RC [-2], "','", RC [-1], "');") ") the insert statement is generated, as you can see in the Excel file in the example (when you click the cell below SQL, you can see the formula ). If there is a date format, use the following aspect = concatenate ("insert into employee (name, birthday, email, holobby) values ('", RC [-4], "', '", text (RC [-3]," yyyy-mm-dd hh: mm: SS "),"', '", RC [-2],"', '", RC [-1],"'); ") here, the text function is used to format the date into a date string that MySQL can accept. method 2. If you want to import an Excel table to the MySQL database, Step 1: select the data to be imported and add another column, for example, Step 2: copy the selected data to a new table workbook, then "Save as"-"" text file (Tab segmentation )(*. TXT) ", if saved to the location" D: \ data.txt. Step 3: Create a MySQL database and table based on the data to be imported, and then run the command load data local infile 'd: \ data.txt 'into table exceltomysql fields terminated by '\ T '; import. For example, all the data has been imported into mysql. Let's select it. Here, the data has been converted from Excel to MySQL. Next, the process of converting data from MySQL to excel is actually a text file separated by a tab. If you want to import the boy information in this table to excel, you can. Select * into OUTFILE 'd: \ man.txt 'from exceltomysql where xingbie = "male"; in this way, all boys' information in the table is output to be separated by tabs, '\ n' in the text file D: \ man.txt. You can open the Excel file, select "data"> "Import external data"> "import data", select "D: \ man.txt", and click "OK. Prepared by xyaxlz
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.