Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing data into an auto incremented table

Status
Not open for further replies.

jondubya

Technical User
Apr 16, 2005
13
0
0
GB
I'm guessing this is a fairly common request and it's so obvious that I can't find an answer on the web after half hour of searching.

My problem is this: I've already a table constructed with usernames and details, and the UserID field for this table autoincrements. I now have a list of users in excel format I wish to add. I've tried leaving the UserID column in my excel list blank in the hope it will autoincrement but it just fails.

Any pointers? TIA jondubya
 
You don not need to include a UserID column in your Excel sheet in order for the field to auto-increment.
 
That doesn't seem to work, I've removed the UserID column from the excel file and imported that file with one column short.

This only results in the next column being entered one column earier, this doesn't work as the next column is the name field.

I'm importing using Navicat but that shouldn't make any difference, it's the autoincrement value that's causing the problem. One way could be to remove the UserID field, enter the data and create a new UserID field, but I would then lose all previous references. Any ideas?
 
export the excel file as csv then use LOAD DATA INFILE to import it into mysql. You can specify the exact columns you are importing and properly ignore your first column, which would then update accordingly.

sorry I have no experience with navicat so can't tell you exactly what you would need to do the same thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top