I have a table qotwVote1a
with fields QuestionId, MemberId, Vote1a
where QuestionId
and MemberId
are the primary key.
I want to run a query to find that a member, has voted for a question or not. If not, I set the variable $j
to 0
, if yes I set it to 1
.
I wrote this query. But it is giving me an error. Can someone have a look at it? And if you want to ask anything more, let me know.
$questionId=57;
$id="zee";
$result2 = mysql_query("
SELECT MemberId
FROM qotwVote1a
WHERE QuestionId='".$questionId."'
AND MemberId='".$id."'
AND MemberId NOT IN ('
SELECT MemberId
FROM qotwVote1a
WHERE QuestionId='".$questionId."'
')
");//WHERE QuestionId='".$questionId."'
$j=0;
echo $result2;
while($row2 = mysql_fetch_array($result2))
{
echo $row2['Vote1a']." ".$row2['QuestionId']." ".$row2['MemberId']; echo "<br/>";
$j=1;
}
echo($j);