StudentCodingHUB

Use programming to create innovative things.
  • new post

    Sunday, 26 April 2015

    How to import data from Excel to mysql table

    Excel to mysql table

    • Convert your MS Excel Document into csv data. 

    How to convert an existing Excel file into a .csv format:

    • Open your excel file. 
    • Click on File and Save as. 
    • Select where you would like to save the file (like your desktop or a drive). 
    • In the File Name area, name your document. 
    • In the Save as Type area, select CSV(Comma Delimited) from the pull down menu.
    • Click Save. 
    • You may receive one or two warning about the formatting of .csv, click yes. 

    Export mysql table data to file

    select actor_id, first_name, last_name
    into outfile 'C:/Users/joges/Desktop/aaajoges.txt'
    from actor;


    .CSV file

    SELECT idparent, number INTO OUTFILE 'C:/Users/joges/Desktop/resultjoges.csv'
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    ESCAPED BY '\\'
    LINES TERMINATED BY '\n'
    FROM parent

    Load DATA from .csv file

    load data local infile 'C:/Users/joges/Desktop/Book1.csv' into table parent fields terminated by ','
    enclosed by '"'
    lines terminated by '\n'
    (idparent, number)

    No comments:

    Post a Comment