sungpeng Posted November 15, 2012 Share Posted November 15, 2012 $instclasses = mysql_query("SELECT * FROM people where pid='$doin[pid]' OR cpid='$doin[pid]' AND pid='$_POST[cpid]' OR cpid='$_POST[cpid]'"); Am I getting the "or" "and" correct ? Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/ Share on other sites More sharing options...
sungpeng Posted November 15, 2012 Author Share Posted November 15, 2012 $instclasses = mysql_query("SELECT * FROM people where (pid='$doin[pid]' OR cpid='$doin[pid]' ) AND (pid='$_POST[cpid]' OR cpid='$_POST[cpid]'")); Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392533 Share on other sites More sharing options...
AyKay47 Posted November 15, 2012 Share Posted November 15, 2012 Is the query returning expected results? Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392562 Share on other sites More sharing options...
RayTaylorII Posted November 15, 2012 Share Posted November 15, 2012 (edited) Am I getting the "or" "and" correct ? add Parentheses () to tell sql how to evaluate it... $instclasses = mysql_query("SELECT * FROM people where pid='$doin[pid]' OR (cpid='$doin[pid]' AND pid='$_POST[cpid]') OR cpid='$_POST[cpid]'"); not sure if this is your intent, but you get the idea of using the "()" to control the grouping Edited November 15, 2012 by RayTaylorII Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392644 Share on other sites More sharing options...
AyKay47 Posted November 15, 2012 Share Posted November 15, 2012 add Parentheses () to tell sql how to evaluate it... $instclasses = mysql_query("SELECT * FROM people where pid='$doin[pid]' OR (cpid='$doin[pid]' AND pid='$_POST[cpid]') OR cpid='$_POST[cpid]'"); not sure if this is your intent, but you get the idea of using the "()" to control the grouping The OP is using () already in his second post. Also OP, we cannot tell you whether or not the query is correct for what you are trying to do without knowing what you are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392673 Share on other sites More sharing options...
Barand Posted November 15, 2012 Share Posted November 15, 2012 (edited) Unless we hear to the contrary I think we just have to assume the second post was his solution. Edited November 15, 2012 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392698 Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2012 Share Posted November 15, 2012 Yeah, that would be my guess too. Quote Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392721 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.