1

I'm trying to import my CSV data file back into my database in the same order it is in the CSv file. However when I import the order is all jumbled from how it appears in the file.

Is there a way to force PHPmyadmin to import in the exact same order as the CSV?

Mark
  • 61
  • 1
  • 1
  • 4
  • See my answer http://stackoverflow.com/questions/8138193/how-to-export-in-phpmyadmin-not-include-id-column-the-auto-increment-coloumn/8138264#8138264. This way you can export any result set of your query. – matino May 14 '12 at 08:02

2 Answers2

0

I think it does import in the same order. But MySQL sometimes does silly things.

In PHPMyAdmin, click on your table. Then click on the "Operations" tab. You will see an option for "Alter table order by".

Select the field you want to order by and the direction and click Go.

voila.

Buttle Butkus
  • 9,206
  • 13
  • 79
  • 120
0

SQL databases don't have an order by default. If you want ordering, provide a column to sort on, then use this column in ORDER BY in your queries.

For your situation, you could look at making an autoincrement primary key. This key will increment with your import and then be suitable for your requirements.

Habbie
  • 2,150
  • 15
  • 17
  • Okey but a CSV of only 216 items goes into the DB in the same order as I have in my CSV file. But when I do the CSV with 547 items it is jumbled order in the table. – Mark Oct 08 '10 at 14:26
  • Yes. "It depends". Use ORDER BY. – Habbie Oct 18 '10 at 09:42