thank you, that was helpful.
I should tell you that my problem was much more complex than this, but the syntax still worked. See, both "foo" and "bar" are actually ids of other tables, and sometimes there are more than two values of bar that I want to check - but I don't want to check these IDs, I want to check usernames which are in another table. In case you are curious, here's the code I eventually came up with to build the query ($includeList is a comma-delimited list of usernames - topicId is "foo" and authorId is "bar", but I actually want the username associated with the authorId):
$usersArray = explode(",",$includeList);
$numUsers = sizeof($usersArray);
$q1 = "SELECT distinct m0.topicId from $cmessages m0 ";
$q2 = "left join $cusers u0 on (m0.authorId=u0.authorId) ";
$q3 = "where (u0.username='".$usersArray[0]."'";
$q4 = ")";
for($i=1; $i<(sizeof($usersArray)); $i++) {
$q1 .= ("left join cmessages m".$i." on (m0.topicId=m".$i.".topicId) ");
$q2 .= ("left join cusers u".$i." on (m".$i.".authorId=u".$i.".authorId) ");
$q3 .= (" AND u".$i.".username='".$usersArray[$i]."'");
}
$topicResult = mysql_query($q1.$q2.$q3.$q4);