Jump to content

Where "or" "and"


sungpeng

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.