Duplicate entry in table

Discussion in 'PHP' started by rob7676, Dec 8, 2008.

  1. #1
    I will try to explain this as easy as possible. I have a system on "server 1" the records data from a phone system and on "server 2" it records data from an online report. Now, in my table I am getting an error of Duplicate entry for a specific time (time column) when there are entries that have the same time, but not all the same data. How can I get it to not do that? There maybe many entries with the same time but not the same data for as long as this system is running because thats the time the report was made. So again, how do I get it not to assume its the same? Please help.
     
    rob7676, Dec 8, 2008 IP
  2. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    add a field to the table to signify whether it's from source #1 or #2.
    
    alter table [tablename] add column source varchar(2);
    
    Code (markup):
    then fill that column accordingly
     
    rene7705, Dec 8, 2008 IP
  3. rob7676

    rob7676 Peon

    Messages:
    82
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How would that make a difference? What if 2 reports were made at the same time and came from the same place, is it still going to give me the dup error?
     
    rob7676, Dec 8, 2008 IP
  4. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes, but that's not what you described earlier.

    if there's more than 1 report coming from the same source, do as before but make it an index field (integer).
     
    rene7705, Dec 8, 2008 IP
  5. rob7676

    rob7676 Peon

    Messages:
    82
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thats way I am confused, I have an id field that is autoinc
     
    rob7676, Dec 8, 2008 IP
  6. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    the id field you leave as is, the primary key for the table would probably become (id, timestamp, index)
     
    rene7705, Dec 8, 2008 IP
  7. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If you're not using the timestamp as the index (as it would seem... you say you have an auto-incrementing ID field), it would seem as though it's been marked it as unique. Recheck the table schema and make sure that is not the case.
     
    TwistMyArm, Dec 8, 2008 IP