Help Importing Csv Into Mysql Database

Discussion in 'MySQL' started by mjp92122, May 8, 2006.

  1. #1
    Hi All,

    I'm a newbie to MySQL and I'm trying to import a .CSV file into my MySQL database but keep getting a this error message:

    ERROR 1062 (23000): Duplicate Entry '4' for key 1

    I've tried it both by using PhpMyAdmin and the MySQL command line prompt and no luck either way. I don't see how it could say the entries are duplicates since the data is different. Any help or suggestions would be greatly appreciated.
     
    mjp92122, May 8, 2006 IP
  2. mjp92122

    mjp92122 Peon

    Messages:
    78
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here's the error message I'm getting from PhpMyAdmin:


    Error
    SQL query:

    INSERT INTO `lawyers` ( `firmID` , `firmName` , `Address` , `City` , `State` , `Zip` , `County` , `Phone` , `Fax` , `Website` , `lname` , `fname` , `practice1` , `practice2` , `practice3` , `practice4` , `email` )
    VALUES (

    '4', 'Ferris & Britton', '401 W A St # 1600', 'San Diego', 'CA', '92101-7906', 'San Diego', '6192333131', '', 'www.ferrisbritton.com', 'Britton', 'Christopher', 'Anti-Trust Licensing', 'Corporate Business', 'Personal Injury', 'Criminal Justice', 'john755@aol.com'
    )

    MySQL said:

    #1062 - Duplicate entry '4' for key 1
     
    mjp92122, May 8, 2006 IP
  3. ajayr

    ajayr Active Member

    Messages:
    322
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #3
    You are having two lines with firmID as 4. Check and if they both contain the same data, delete one of them. Otherwise change the firmID of one of them to something unique.
     
    ajayr, May 9, 2006 IP
  4. mjp92122

    mjp92122 Peon

    Messages:
    78
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's what I don't understand. All the lines have unique firmID's. (starting at 1 to 3,000). I'm wondering if it's maybe the field parameters or something. As a test I tried to just import the first three collumns and that worked just fine, but not with all the fields as shown above.
     
    mjp92122, May 9, 2006 IP
  5. ajayr

    ajayr Active Member

    Messages:
    322
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #5
    While importing just the first three columns, did u ensure that the firmID is set as a primary key?
     
    ajayr, May 9, 2006 IP