Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Delete duplicate fingerprint

Delete duplicate fingerprint

Scheduled Pinned Locked Moved Database
mysqlcomquestionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I would like to ask how can I delete duplicate records in MySQL from my fingerprint table. I need to delete any record if found the same created_date AND created_time AND employee_number Thanks, Jassim

    Technology News @ www.JassimRahma.com

    C B 2 Replies Last reply
    0
    • J Jassim Rahma

      Hi, I would like to ask how can I delete duplicate records in MySQL from my fingerprint table. I need to delete any record if found the same created_date AND created_time AND employee_number Thanks, Jassim

      Technology News @ www.JassimRahma.com

      C Offline
      C Offline
      Chris Quinn
      wrote on last edited by
      #2

      Don't use MySQL but in SQl server you would do this:

      WITH CTE_fingerprint
      AS (
      SELECT
      employee_number
      ,created_date
      ,created_time
      ,ROW_NUMBER() OVER (
      PARTITION BY
      employee_number
      ,created_date
      ,created_time
      ORDER BY
      employee_number
      ,created_date
      ,created_time
      ) AS RowNumber
      FROM [fingerprint]
      )

      DELETE
      FROM CTE_fingerprint
      WHERE RowNumber > 1;

      ========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================

      1 Reply Last reply
      0
      • J Jassim Rahma

        Hi, I would like to ask how can I delete duplicate records in MySQL from my fingerprint table. I need to delete any record if found the same created_date AND created_time AND employee_number Thanks, Jassim

        Technology News @ www.JassimRahma.com

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        Not sure with self-joins in MySQL. This query should show you all the duplicates (assuming ID is the identifier in the table):

        SELECT *
        FROM fingerprint t1 inner join fingerprint t2 on
        t1.created_date=t2.created_date and t1.created_time = t2.created_time and t1.employee_number=t2.employee_number
        Where t1.ID
        Next, change SELECT * to SELECT t1.ID to get the ID values of the duplicates only, then do a delete query with a subquery:

        DELETE
        FROM fingerprint
        WHERE fingerprint.ID IN
        (
        SELECT t1.ID
        FROM ... (see query above)
        )

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups