SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: delete duplicates in column1 and column2

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    delete duplicates in column1 and column2

    hi,
    this is what the table looks like table Product
    I need to delete the duplicate in 'Power Supply' and 'Motherboards' fields
    I've tryed
    Code:
    Delete from Product where `Power Supply`=`Motherboards`
    but it is not working .
    Any idea how to delete them ?

  2. #2
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,462
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    delete both duplicates, or only one of them?
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the 1 located in the `Motherboards` column based on the result from `Power Supplies` column.

  4. #4
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,462
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    Code:
    DELETE t2 
      FROM Product AS t1 
    INNER 
      JOIN Product AS t2 
        ON t2.Motherboards = t1.`Power Supply`
    as always, back up your data before running any SQL that you got off teh interwebs
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tnx for your answer.
    I've inserting the values without the duplicates.

Bookmarks

Posting Permissions

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