#1
  1. No Profile Picture
    kumars
    Guest
    Devshed Newbie (0 - 499 posts)
    How can I import a multiple rows of data into a table using a single INSERT statement.
    Now I have to use INSERT statement for each row, which I want to make simple by one INSERT statement.

    Any help is appreciated.
  2. #2
  3. No Profile Picture
    kumars
    Guest
    Devshed Newbie (0 - 499 posts)
    Iam answering to my own question it is

    LOAD DATA INFILE 'my.data' INTO TABLE myitems;

    Detail: I typed all the data into a Gnumeric Spread sheet and saved it as a SIMPLE TEXT FORMAT and named the file my.data.

    Then using vi edit the my.data file and remove the first line 'sheet 0' (I need to
    find a way to automate this).

    Then loged into mySQL usig id and password:
    mysql -u root -p
    password:*******

    then use the database:
    mysql> use mydatabase;

    then do this to import the text file
    LOAD DATA INFILE 'my.data' INTO TABLE items;

    bingo, I get couple of warnigns but confirmed the data has added properly as i needed.

    You can visit my demo database at
    <A href="http://pricelane.tzo.com">PriceL@ne.com</A> and then follow the PriceL@ane Link.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    1
    Rep Power
    0
    In which directory does the INFILE have to be placed?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Posts
    9
    Rep Power
    0
    INFILE is part of the syntax.
    my.data is the file name.
    my.data can be placed anywhere but include the relative path if it is not in the place from where u had started the MySQL.

    Hope this helps.

Similar Threads

  1. updating a field in a table with the rows rank
    By thatcoryguy in forum MySQL Help
    Replies: 0
    Last Post: January 3rd, 2004, 12:11 AM
  2. updating multiple rows (MySQL)
    By Edison in forum PHP Development
    Replies: 2
    Last Post: October 3rd, 2003, 08:05 AM
  3. Retrieving multiple rows
    By Entemedia in forum PostgreSQL Help
    Replies: 1
    Last Post: October 10th, 2001, 03:15 AM
  4. Retrieving data from multiple rows
    By Entemedia in forum MySQL Help
    Replies: 1
    Last Post: September 30th, 2001, 07:10 AM
  5. Filling a dropdown menu with table rows
    By voyd1 in forum PHP Development
    Replies: 5
    Last Post: March 14th, 2001, 10:01 AM

IMN logo majestic logo threadwatch logo seochat tools logo