edoceo: Latin "to inform fully, instruct thoroughly"

SQL Find Duplicate IDs


Use the following SQL snip to find duplicated ID or columns on tables. This may necessary when trying to promote a column to a primary key or when attempting to add a unique index.

  
select distinct id,count(id) from invoice_item group by id having count(id) > 1;

Results may be like:

  956 |     2
  957 |     2
  958 |     2
  959 |     2
XHTML 1.1. and CSS2.1/3 © 1999-2008 Edoceo, Inc.
Edit this Page