TechTalk: A quick way to list duplicate records with SQL.

SQL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Here is a quick way to list duplicate rows in a table using an SQL SELECT statement with a subquery:

 SELECT * FROM orders WHERE custno IN (SELECT custno FROM orders GROUP BY custno HAVING COUNT(*) > 1) ORDER BY custno 

This SQL statement will produce a list containing every column of the rows in the orders table that contain a duplicate customer number.

- Robert Riches

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$