Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
vinoth
- Forum Contributor
- Posts: 113
- Joined: Thu Aug 02, 2007 3:08 am
- Location: India
-
Contact:
Post
by vinoth »
Hi
I am working on PHP project..
The client sent the details in CSV file is there any possible way to insert the data into Mysql
Help me by providing some suggestions & guidelines to achieve this
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
Take a look at LOAD DATA FROM INFILE
-
kalfsnor
- Forum Newbie
- Posts: 3
- Joined: Thu Sep 27, 2007 7:44 am
Post
by kalfsnor »
if you have access to PHPadmin you could use "import", no? set file format to CSV.
-
vinoth
- Forum Contributor
- Posts: 113
- Joined: Thu Aug 02, 2007 3:08 am
- Location: India
-
Contact:
Post
by vinoth »
hi..
Sorry for late reply..
If I use Load inline function it was inserted into an single table.
But I want to split the rows of the CSV file and insert into 4 different tables..
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
You will need to write some code to do that then.
-
VladSun
- DevNet Master
- Posts: 4313
- Joined: Wed Jun 27, 2007 9:44 am
- Location: Sofia, Bulgaria
Post
by VladSun »
feyd wrote:You will need to write some code to do that then.
It could be done only with SQL queries, without PHP code (this is still "some code"

).
There are 10 types of people in this world, those who understand binary and those who don't
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
VladSun wrote:It could be done only with SQL queries, without PHP code (this is still "some code"

).
It would require multiple calls to LOAD DATA INFILE, not a single query. It may as well be code handling it at that point.
-
VladSun
- DevNet Master
- Posts: 4313
- Joined: Wed Jun 27, 2007 9:44 am
- Location: Sofia, Bulgaria
Post
by VladSun »
feyd wrote:VladSun wrote:It could be done only with SQL queries, without PHP code (this is still "some code"

).
It would require multiple calls to LOAD DATA INFILE, not a single query. It may as well be code handling it at that point.
Or one call to LOAD DATA INFILE, multiple calls to INSERT ... SELECT, and DROP the first table - that is what I meant. Just pure SQL

There are 10 types of people in this world, those who understand binary and those who don't