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

Home -> Community -> Usenet -> c.d.o.server -> Re: Delete records which has referance to the same able

Re: Delete records which has referance to the same able

From: Andy Hassall <andy_at_andyh.co.uk>
Date: Mon, 28 Aug 2006 14:18:46 +0100
Message-ID: <28r5f2dtrggsaugi2dl6hroe08jsikagov@4ax.com>


On 28 Aug 2006 05:52:47 -0700, swadeep.c_at_gmail.com wrote:

>i have a table in which the foreign key referance is to another column
>in the same table.
>
>Now is there any query to delete both the records the child and the
>parent using a single sql query.
>
>the table stucture is as follows
>
>ID, FDB_ID, STD_ID, etc
>
>here FDB_ID id the foreign key for ID
>
>ID FDB_ID ROLL REG_NO ST CD
>38 37 364 929560 491 S
>37 364 929560 491 F
>
>the second record is the parent and the first is the child
>
>Now i need to delete both the records using a single sql query. Can you
>pleas give the query??

 DELETE FROM tab WHERE ID IN (37, 38);

 Or set ON DELETE CASCADE on the foreign key and delete just the parent.

-- 
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Received on Mon Aug 28 2006 - 08:18:46 CDT

Original text of this message

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