Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Location
    Finland, Hollola
    Posts
    285
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Deleting duplicated keys from mysql, how?

    Hi,

    I have a mysql table which has duplicated content. I want to delete all duplicated content, except leave one row. any suggestions?
    PHP 5 & MySQL 5 (Y)

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    for a mysql question post in the mysql forum I'd suggest.

    But yes you can do this:

    Code:
    ALTER IGNORE TABLE
    tablename
    ADD droplater UNIQUE(column1, column3, column4)
    and later drop the index or leave it in as necessary.

    you have to include all the columns that you want unique, and that is unique across those columns. for instance I left out column2 so you could have two rows with same info in columns 1,2,3 or 1,2,4 but not 1,3,4


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •