Jim R Posted June 7, 2018 Share Posted June 7, 2018 SELECT paid,nameFirst,nameLast,college,feet,inches,phoneMobile,email FROM college_league_2018 WHERE confirm ='1' AND teamplayer='player' AND (college != 'Wabash' OR college != 'DePauw') ORDER BY college, nameLast This seems simple, and I've found a few examples saying to use parentheses. It's not working. I want individuals where... confirm = 1 teamplayer = player who don't attend Wabash or DePauw My results still include individuals who attend both schools. When I remove the OR and just exclude one of the schools, it works. Quote Link to comment https://forums.phpfreaks.com/topic/307353-multiple-ands-and-an-or-in-a-where-clause/ Share on other sites More sharing options...
element121 Posted June 7, 2018 Share Posted June 7, 2018 I would write it like this using IN or rather in this case NOT IN: AND (college NOT IN ('Wabash','DePauw')) Does that give you what you are after? I find it a lot easier to read. Hope that helps, Jon 1 Quote Link to comment https://forums.phpfreaks.com/topic/307353-multiple-ands-and-an-or-in-a-where-clause/#findComment-1558814 Share on other sites More sharing options...
Barand Posted June 7, 2018 Share Posted June 7, 2018 When you are using "not equals" the OR needsd to be an "AND". Although I agree with element121, "(NOT) IN" is a lot easier than multiple ORs 1 Quote Link to comment https://forums.phpfreaks.com/topic/307353-multiple-ands-and-an-or-in-a-where-clause/#findComment-1558815 Share on other sites More sharing options...
Jim R Posted June 7, 2018 Author Share Posted June 7, 2018 Thank you both! Quote Link to comment https://forums.phpfreaks.com/topic/307353-multiple-ands-and-an-or-in-a-where-clause/#findComment-1558819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.