當我運行這個MySQL查詢時,它不返回任何結果。我相信這一定是一個語法錯誤,但我不能看到我錯了:MySQL JOIN查詢不返回任何結果
這裏是我的查詢:
$table_search = mysqli_query($mysqli, "SELECT tables.* FROM tags ON tags.post_id = tables.post_id WHERE tables.post_id = ".$post['id']." AND tags.tag = ".$tag);
我知道這兩個$post['id']
和$tag
都沒有問題,因爲我有檢查這些變量,並且它們都返回了被忽略的值。有一次,我已經跑了我的查詢我計劃輸出數據,像這樣:
while($table = mysqli_fetch_array($table_search)) {
echo $table['content'];
}
當我在我的腳本運行錯誤報告是這樣的錯誤:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /Users/.../search.php on line 63
我不知道如何解決這個問題或者我的代碼有什麼問題。
哪來的'JOIN'語法? – ekad 2014-10-07 07:13:44
您在查詢時發生錯誤。可能你需要從: 選擇...從表加入tags上的標籤.post_id = tables.post_id ... – krynio 2014-10-07 07:16:28