August 27th, 1999, 10:44 PM
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.
August 28th, 1999, 08:09 AM
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
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.
In which directory does the INFILE have to be placed?
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.