mysql - how to get subject with and or condition? -
select distinct a1.id m a1, m a2 on a1.id = a2.id a1.sub = 'physics' , a2.sub <> 'chem';
i want student who' has taken physics not chem?
giving me wrong result?
any inputs?
by using not exists
:
select * m a1 a1.sub = 'physics' , not exists (select 1 m id = a1.id , sub = 'chem')
Comments
Post a Comment