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 ? 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]'")); 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? 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 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 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. 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 Unless we hear to the contrary I think we just have to assume the second post was his solution. 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. Link to comment https://forums.phpfreaks.com/topic/270714-where-or-and/#findComment-1392721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.