#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    3
    Rep Power
    0
    Hi,
    I want to delete duplicate rows within a table for creating an unique index after this.
    How can I do this with the delete statement or something like this?
    Thanks !
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    The best way to do this would be to add an auto incement column(id), then delete the records you want by referencing them by the id
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    3
    Rep Power
    0
    Thanks for the help! I have added an unique column in this table. But how can I select records with same value in one field and delete all duplicate rows (maybe something like 'not distinct') ?
    Thanks!
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Just thought of this...the easiest way to do this would be to create a second table, with your auto_increment column and unique index. Then, select * from the first table and insert the data into the new table. Rows that are duplicates will be rejected by the new table due to the unique constraint.

    ---John Holmes...
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    3
    Rep Power
    0
    Yes, that should be working. Thanks again, John!

Similar Threads

  1. Table/Query structure - enforce no duplicate rows
    By MJEggertson in forum MySQL Help
    Replies: 3
    Last Post: November 24th, 2003, 12:55 PM
  2. Need help with deleting duplicate records
    By vb.net in forum Database Management
    Replies: 3
    Last Post: October 28th, 2003, 12:34 PM
  3. Deleting a range of rows
    By gmhafiz in forum MySQL Help
    Replies: 4
    Last Post: September 2nd, 2003, 11:27 AM
  4. 5 table join returning too many rows of duplicate data
    By DC Dalton in forum PostgreSQL Help
    Replies: 13
    Last Post: August 14th, 2003, 01:31 AM
  5. Cronjob madness
    By eliteboo in forum Linux Help
    Replies: 10
    Last Post: July 14th, 2003, 10:49 AM

IMN logo majestic logo threadwatch logo seochat tools logo