DevSnips.com Code Snippet Repository
search:    


Navigation
  Home
About
Library
Contact
 
Snippet Library
  ColdFusion   338  
  ASP   201  
  PHP   101  
  HTML   11  
  JavaScript   77  
  XML   2  
  CSS   5  
  SQL   13  
  JSP   2  
  C#   1  
  ASP.NET   0  
  Submit a Code Snippet
 
Blog Archive
  September 2007
August 2007
July 2007
June 2007
May 2007
November 2006
October 2006
Search Archives
 
Random Affiliates
  PHP Arch
Tom Morris
BioMetric Base
ReviewMe!

Want to become an affiliate?
Read more...


Privacy Policy
© 2012

Snippet Library

SQL - Structured Query Language (.sql)


Remove Duplicate Rows from a Database

 
The following SQL example shows you how to eliminate all duplicate rows from a table. This example will only work with a table which has at least one column that is unique for every row. In this example the SQL will remove all rows that have duplicate cust_email's in another row. This example keeps the row with the minimum cust_id which happens to be the primary key for this particular table and then eliminates the duplicate rows that have the same cust_email but different cust_id. The key to solving this problem is to pick a column that is unique for every row and a column that you want to eliminate duplicates for. Then all you need to do is substitute these values in the example below. I am currently working on a solution which will work with multiple columns which I will post later this month.
 
 
 
Go Back





Advertisements

http://promotions.newegg.com/Misc/free_shipping/in