View previous topic :: View next topic
|
Author |
Message |
wastedmaky
New User
Joined: 06 Oct 2006 Posts: 5 Location: manila, philippines
|
|
|
|
I have a query which selects 4 equal records, i want to keep the 1st record and delete the rest. Can anyone help me on how the query should go?
Thanks for your help..
-=wastedmaky=- |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It would help if you clarify "4 equal records". What if more or less than 4 meet the selection criteria?
You could declare a cursor, fetch the rows that meet the selection criteria, and delete the rows fetched after the first one.
If you post some example rows, it may help us understand your requirement. You example should include rows that would be selected and rows that would not. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
I have a query which selects 4 equal records |
Is your query designed to select only 4 records, neither less nor more.
Quote: |
i want to keep the 1st record and delete the rest. |
Delete from where, from the query results or from the table |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
If the rows are identical all the way through, a DELETE FROM Table WHERE is going to delete all 4 rows. He needs to save one off in memory, delete all of them and then put one back in. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
Back to top |
|
|
md nisar
New User
Joined: 14 Sep 2007 Posts: 2 Location: pune
|
|
|
|
please check the ROWID of that 4 records ...then delete records based on the rowid. |
|
Back to top |
|
|
|