Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Deleting 1 and only 1 row from database
In article <715e8m$kjq$1_at_nnrp1.dejanews.com>, <NOSPAMstannon_at_yahoo.com> wrote:
>
> I have a database that has no primary key defined. The database allows
>dulplicate records. I want to remove some of the duplicate records so I
>thought of using "delete", but looking at the syntax, it seems the delete
>command will delete every matches, which is different from my goal -
>only the first matched record.
>
> Can anyone show me the syntax for deleting only 1 record (say, the
>first match)? Thanks!
Use the pseudocolumn ROWID to pick the one you want to delete. Say,
delete from foo
where rowid in (select min(rowid) from foo where bar = 'baz');
Received on Tue Oct 27 1998 - 00:00:00 CST