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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -