bech64 Posted August 8, 2012 Share Posted August 8, 2012 When I run this query, It returns 'status' open or closed. Any help would be greatly appreciated! SELECT * FROM `ticket` WHERE status = 'open' AND helptopic = '* Tech Tuesday (Team 1)' OR helptopic = '* Tech Tuesday (Team 2)' OR helptopic = '* Tech Tuesday (Team 3)' OR helptopic = '* Tech Tuesday (Team 4)' Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/ Share on other sites More sharing options...
smerny Posted August 8, 2012 Share Posted August 8, 2012 i'm assuming you are getting only the "open" status rows of Team 1, but "open" and "closed" for the other teams? put parens around all the helptopic conditionals Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/#findComment-1367772 Share on other sites More sharing options...
bech64 Posted August 8, 2012 Author Share Posted August 8, 2012 Hello and Thank you for your quick reply! That is correct I only get the open for Team 1 but both for the others Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/#findComment-1367774 Share on other sites More sharing options...
Christian F. Posted August 8, 2012 Share Posted August 8, 2012 You'll find the answer to why here: http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html Quite easy fix, same as in mathematics, so you should be able to spot the solution as soon as you know what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/#findComment-1367775 Share on other sites More sharing options...
bech64 Posted August 8, 2012 Author Share Posted August 8, 2012 I am off to a quick meeting, and then I will see if I can figure it out! Unfortunately I am quick the hack. All I know, I have learned from trial and error, and picking apart stuff that works and trying to put it back together to fit my needs. Thanks for your help and if I can't figure out what I need from the info you have given me, I'll be baaaack! Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/#findComment-1367787 Share on other sites More sharing options...
fenway Posted August 11, 2012 Share Posted August 11, 2012 An IN() clause would have saved you a lot of headaches. Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/#findComment-1368540 Share on other sites More sharing options...
jardrake Posted August 19, 2012 Share Posted August 19, 2012 Am I crazy or is that WHERE only applicable to the first *Tech Tuesday (Team 1). I believe you are wanting that WHERE applied to all four right? If so, I think you must use another set of () Quote Link to comment https://forums.phpfreaks.com/topic/266808-query-gets-more-than-expected/#findComment-1370718 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.