0
當我運行查詢時,它返回所有正確的值,除了它不返回任何值,其中a.Correct = null(即一個測驗問題根本沒有被回答),但它確實返回值爲a.Correct = 0PHP RIGHT JOIN查詢不考慮null?
/***Configure the retest***/
public function CreateRetest($topicID) {
$retestData = array();
$count = 0;
$createSQL = "SELECT q.QuestionID,q.Question,q.Answer,q.TopicID From quizanswered a RIGHT JOIN question q ON a.QuestionID = q.QuestionID where (a.Correct=null OR a.Correct = 0) AND q.TopicID = '$topicID'";
$create = mysqli_query($this->db,$createSQL) or die(mysqli_connect_errno()."Cannot create tables");
while($row = mysqli_fetch_array($create)){
$rQuestionID = $row['QuestionID'];
$rQuestion = $row['Question'];
$rAnswer = $row['Answer'];
$retestData[$count] = array($rQuestionID,$rQuestion,$rAnswer);
$count +=1;
}
return $retestData;
}
你的問題是不相關的PHP。刪除PHP標籤和所有的PHP代碼,並保持**只有** SQL查詢 – Dekel