Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Deleting 1 and only 1 row from database

Re: Deleting 1 and only 1 row from database

From: Cheng-Jih Chen <cjc_at_interport.net>
Date: 1998/10/27
Message-ID: <715j7v$i1c$1@interport.net>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US