Delete duplicate records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coachafrane
    New Member
    • Mar 2014
    • 7

    #1

    Delete duplicate records

    I have a form that collects data onto a table called "Dailyattendanc e" with columns "Cardno", "Name", "Sex", "Age" and "Dateofattendan ce".

    In preventing duplicate records i would like to delete records that matches criteria of same cardno, name, and dateofattendace .

    Can i please get help as to achieving that, probably with a code.

    Pls note: Very new to VB

    Thank you.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    some thing like
    Code:
    INSERT INTO MAIN
    SELECT X1.itemnumber AS itemnumber
    FROM X1
    WHERE not exists (select itemnumber
    from MAIN
    where MAIN.itemnumber = X1.itemnumber);
    (source: here)


    takes care of inserting only 1 record (if you expand this query with your own criteria)

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Luuk, I don't think that is what op is after.

      Coachafrane, your question needs an example if would you please because as worded the question makes very little sense. What you are descibing makes it sound like there is a flaw in the design of the database

      Sent from ipad

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        @zmdb: maybe this is not what OP is after,
        I translated:
        "In preventing duplicate records i would like to delete records ..."
        to:
        Why insert records that you do not want, and delete them afterwards. It would be simpler to not insert them at all.

        But let's wait what OP (=coachafrane) has to say.....

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          Luuk,
          That was one way I read the question and the other was that the records need to be "updated" with new or different information.

          Comment

          Working...