Skip to content
Advertisement

Deleting records from particular TABLE – Oracle SQL

I have 1 table i.e. TABLE_1 which has 2 columns i.e. ROLL_NO, ID

I have another 2 tables i.e. TABLE_2 with 3 columns ROLL_NO, LINE_NO, CODE and TABLE_3 with 2 columns i.e. NAME, ORIG_CODE

My question is I need to delete the records from TABLE_1 using other 2 tables TABLE_2 and TABLE_3 in such a way that if any of the LINE_NO of TABLE_2 contains ‘AAA’ of particular ROLL_NO, don’t delete that ROLL_NO from TABLE_1.

This is the oracle code I have written but it is not working as expected:

In above code, we can see that LINE_NO 2 and 3 don’t have CODE as ‘AAA’ so that particular ROLL_NO is getting deleted from TABLE_1 which I don’t want.

If any LINE_NO has CODE as ‘AAA’ don’t delete from the TABLE_1

Advertisement

Answer

Try this:

Regards…

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement