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. |
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 ...
|
|||||||
|
|||
|
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 |
| Sponsored Links |
|
|||
|
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 |
| The Following User Says Thank You to jbanx For This Useful Post: | ||
|
|||
|
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- |
|
|||
|
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... |
|
|||
|
Re: Delete duplicate records without using "rowid"
Quote:
Thanks |
|
|||
|
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); |
|
|||
|
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) ) |
|
|||
|
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) ) |
|
|||
|
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); |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
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 |