I have an Access file, and a MySQL database.
I need to import that data from the Access table into the existing MySQL table.
Some fieldnames differ, but I can alter them in Access before I do anything.
I'm assuming it's be some kind of "INSERT" query, but I've never done it with a bulk of existing data into a query.
Can anyone help please?
Importing bulk existing data into separate existing sql db
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Importing bulk existing data into separate existing sql db
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Importing bulk existing data into separate existing sql db
Hi Simon,
First of all you'll need to be able to read the Access file from PHP right? - Is this how you were thinking about doing it?
First of all you'll need to be able to read the Access file from PHP right? - Is this how you were thinking about doing it?
Re: Importing bulk existing data into separate existing sql db
I think fgetcsv is what you need to find out about. http://uk2.php.net/manual/en/function.fgetcsv.php
Something like
you could make a new mysql table and then design some sort of filter to put the right fields in your existing database.
Hope this helps
Something like
Code: Select all
$handle = fopen ("document.csv","r");
while ($data = fgetcsv ($handle, 1000, ",")) {
// then make an insert
}
Hope this helps
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Importing bulk existing data into separate existing sql db
I've used fgetcsv() numerous time before and it has always worked out perfectly.