Reputation: 95
I have columns as below
----------------------------
brandb model class
nokia x2 2nd
nokia lumina 1st
sony xperia 1st
sony xperial 2nd
sumsun deo1 1st
sumsun deo2 1st
------------------------------------------------------------------------
o/p
sunsun deo1 1st
sumsun deo2 1st
I want to remove the brands NOKIA brand and sony completely if it contains 2nd class row product from ORACLE SQL query.
many thanks in advance
Upvotes: 0
Views: 24
Reputation: 1269443
If you really want to delete the rows from the table, then you can try:
delete from table
where brandb in (select t2.brandb from table t2 where t2.class = '2nd');
If you just want to return a query without those models:
select t.*
from table t
where t.brandb not in (select t2.brandb from table t2 where t2.class = '2nd');
Upvotes: 1
Reputation: 424973
Try this:
delete from mytable
where brandb in (
select brandb from myable
where class ='2nd')
Upvotes: 0