In this way we can find duplicate entry in the database
-- create table for test data
create table test_data (
id int,
product char(10)
)
-- insert test data
insert into test_data values(1,'item 1')
insert into test_data values(2,'item 2')
insert into test_data values(3,'item 3')
insert into test_data values(3,'item 4')
insert into test_data values(5,'item 5')
insert into test_data values(5,'item 6')
insert into test_data values(5,'item 7')
insert into test_data values(8,'item 8')
-- find duplicate id
select id, count(*) #_of_dups
from test_data
group by id
having count(*) > 1
-- drop table test_data
drop table test_data
No comments:
Post a Comment