question table
========================
question_id
1
2
3
4
user_answer table
========================
user_id question_id
33 2
44 4
33 1
44 3
此代碼將返回問題ID(2和1) 什麼,我想要的是檢索表的問題其他問題的ID,所以我想 的結果是(3,4)SQL左外連接選擇不匹配的記錄?
$fadi = mysql_query("SELECT * FROM question
LEFT OUTER JOIN user_answer
ON user_answer.question_id = question.question_id
WHERE user_answer.user_id = 33");
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array($fadi))
{ Print "<tr>";
Print "<th>question </th> <td>".$info['question_id'] . "</td></tr>";
} Print "</table>"; }
在您的SQL查詢中將33更改爲44 – twoleggedhorse
使用mysqli而不是mysql代替新代碼。 –
不,我想從問題故事中找回未回答的問題,然後將問題ID添加到用戶標識爲這樣: user_id 33 44 33 44 33 33 question_id 2 4 1 3 3 4 –