Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Delete duplicate records without using "rowid"

This is a discussion on Delete duplicate records without using "rowid" within the SQL forums, part of the Databases category; Question asked by visitor Joe Hi all! Good Evening. I would like to know if it is possible to delete duplicate records from a table with out using "rowid" using ...

Go Back   Geeks Talk > Databases > SQL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 04-17-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 192 Times in 154 Posts
Geek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura about
Delete duplicate records without using "rowid"

Question asked by visitor Joe

Hi all! Good Evening.

I would like to know if it is possible to delete duplicate records from a table with out using "rowid" using MYSQL only. Can use "rownum". Plz help me in this regard.

Thanx in advance.
Bye
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-18-2007
Expert Member
 
Join Date: Jun 2006
Location: India
Posts: 413
Thanks: 15
Thanked 43 Times in 31 Posts
jamesravid will become famous soon enough
Re: Delete duplicate records without using "rowid"

I think you can't do that. Because Rownum is not linked with any record.
__________________
Cheers,
:) James:)
Reply With Quote
  #3 (permalink)  
Old 04-23-2007
Junior Member
 
Join Date: Feb 2007
Location: Bangalore
Posts: 17
Thanks: 0
Thanked 2 Times in 2 Posts
jbanx is on a distinguished road
Re: Delete duplicate records without using "rowid"

One example is here
create table t1(col1 int, col2 int, col3 char(50))
insert into t1 values (1, 1, 'data value one')
insert into t1 values (1, 1, 'data value one')
insert into t1 values (1, 2, 'data value

SELECT col1, col2, count(*)
FROM t1
GROUP BY col1, col2
HAVING count(*) > 1

delete from t1
where col1=1 and col2=1
Reply With Quote
The Following User Says Thank You to jbanx For This Useful Post:
  #4 (permalink)  
Old 04-23-2007
Expert Member
 
Join Date: Dec 2006
Location: Chennai
Posts: 203
Thanks: 2
Thanked 17 Times in 15 Posts
Barbie is on a distinguished road
Re: Delete duplicate records without using "rowid"

Jaiprakash,
we need to delete only one of those duplicated rows.
but that delete statement will deletes both.
Reply With Quote
  #5 (permalink)  
Old 04-23-2007
Expert Member
 
Join Date: Nov 2006
Location: Hyd-IND
Posts: 528
Thanks: 1
Thanked 63 Times in 50 Posts
sutnarcha is on a distinguished road
Re: Delete duplicate records without using "rowid"

Yes, it deletes both 1st and 2nd records.

I think there is no solution without using ROWID.
__________________
Lack of WILL POWER has caused more failure than
lack of INTELLIGENCE or ABILITY.

-sutnarcha-
Reply With Quote
  #6 (permalink)  
Old 07-11-2007
Junior Member
 
Join Date: Jul 2007
Location: Chennai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vadaliraghu is on a distinguished road
Re: Delete duplicate records without using "rowid"

Try this....
delete from table where rowid=(select max(rowid) from table group by dup_field_name having count(*) > 2)



Thanks...
Reply With Quote
  #7 (permalink)  
Old 07-12-2007
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,853
Thanks: 9
Thanked 168 Times in 142 Posts
debasisdas has a spectacular aura aboutdebasisdas has a spectacular aura about
Re: Delete duplicate records without using "rowid"

No, that is not possible in oracle..
Reply With Quote
  #8 (permalink)  
Old 07-12-2007
Contributing Member
 
Join Date: Apr 2006
Location: kolkata(now in noida)
Posts: 56
Thanks: 9
Thanked 3 Times in 2 Posts
bhaski is on a distinguished road
Re: Delete duplicate records without using "rowid"

hi
use rank() function to delete these duplicate records in oracle
Reply With Quote
  #9 (permalink)  
Old 11-06-2008
Contributing Member
 
Join Date: May 2008
Location: Chennai
Posts: 30
Thanks: 6
Thanked 0 Times in 0 Posts
sureshkumar.mtech is on a distinguished road
Re: Delete duplicate records without using "rowid"

Quote:
Originally Posted by bhaski View Post
hi
use rank() function to delete these duplicate records in oracle
could you please explain with example query.................


Thanks
Reply With Quote
  #10 (permalink)  
Old 12-06-2008
Junior Member
 
Join Date: Oct 2008
Location: a
Posts: 22
Thanks: 11
Thanked 0 Times in 0 Posts
nathsambu is on a distinguished road
Re: Delete duplicate records without using "rowid"

I think this is not possible in Oracle.
Reply With Quote
  #11 (permalink)  
Old 01-15-2009
Expert Member
 
Join Date: Nov 2008
Location: Chennai
Posts: 303
Thanks: 1
Thanked 37 Times in 32 Posts
amitpatel66 is on a distinguished road
Re: Delete duplicate records without using "rowid"

You can try using analytical function to delete duplciates in oracle
Reply With Quote
  #12 (permalink)  
Old 01-16-2009
Contributing Member
 
Join Date: Dec 2008
Location: bangalore
Posts: 76
Thanks: 0
Thanked 18 Times in 18 Posts
ecearund is on a distinguished road
Re: Delete duplicate records without using "rowid"

Yes it is possible using analytic functions...
I think this one will help you...

select *
from ( select a.*,
row_number() over ( partition by column1 order by column2) r
from table a)
where r >1;

delete from table where (c1,c2,...) in
(Select * from table);
Reply With Quote
  #13 (permalink)  
Old 01-16-2009
Junior Member
 
Join Date: Jan 2009
Location: Lucknow
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
asthutc is on a distinguished road
Re: Delete duplicate records without using "rowid"

Yeah, It's possible in SQL Server 2005
try this...
This query delete duplicate records in one shot....

delete from Table_Name where Column_Name in
(
select Column_Name from Table_Name
group by Column_Name
having (count(Column_Name)>1)
)
Reply With Quote
  #14 (permalink)  
Old 01-16-2009
Junior Member
 
Join Date: Jan 2009
Location: Lucknow
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
asthutc is on a distinguished road
Re: Delete duplicate records without using "rowid"

Yeah, It's possible in SQL Server 2005
try this...
This query delete duplicate records in one shot....

delete from Table_Name where Column_Name in
(
select Column_Name from Table_Name
group by Column_Name
having (count(Column_Name)>1)
)
Reply With Quote
  #15 (permalink)  
Old 01-22-2009
Junior Member
 
Join Date: Jan 2009
Location: Bangalore
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
harishkshetty is on a distinguished road
Re: Delete duplicate records without using "rowid"

Try this

delete from employees emp1 where rowid < (select max(rowid) from employees emp2 where emp1.employee_id=emp2.employee_id);
Reply With Quote
  #16 (permalink)  
Old 01-22-2009
Expert Member
 
Join Date: Nov 2008
Location: Chennai
Posts: 303
Thanks: 1
Thanked 37 Times in 32 Posts
amitpatel66 is on a distinguished road
Re: Delete duplicate records without using "rowid"

@Harishkshetty,

The question is without using a rowid.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Filling "Date Creation" field with the current day Lokesh M Test Director 1 02-27-2008 08:39 AM
Table that houses "field selection" Cayenne SAP R/3 0 04-12-2007 02:02 PM
What is ""developing procedures and scripts (UNIX/Windows/Oracle) spd15 Testing Issues 1 04-04-2007 09:01 AM
Business Objects - parsed failed "ORA-00936: missing expression :-936" JobHelper Data Warehousing 0 02-11-2007 06:06 AM
McAfee launches "TOTAL PROTECTION" Beta Lokesh M Geeks Lounge 0 06-22-2006 08:44 AM


All times are GMT -4. The time now is 11:35 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved