这是我原来有效的查询
Select * FROM story st, sentences s, speaker sp
WHERE (st.lesson_id = '1' AND
st.speaker_id = sp.speaker_id AND
st.sentence_id = s.sentence_id)
当我尝试添加 Order By 时,它崩溃了。
Select * FROM story st, sentences s, speaker sp
WHERE (st.lesson_id = '1' AND
st.speaker_id = sp.speaker_id AND
st.sentence_id = s.sentence_id) ORDER BY st.story_in_lesson_id ASC
无法弄清楚为什么它会破裂。
编辑:
这是我收到的错误 Fatal error: Call to a member function fetch_object()
编辑:
我的 PHP 代码
$result = $mysqli->query("Select * FROM story st, sentences s, speaker sp
WHERE st.lesson_id = '1' AND
st.speaker_id = sp.speaker_id AND
st.sentence_id = s.sentence_id
ORDER BY st.story_in_lesson_id ASC");
while ($value = $result->fetch_object()) {
//never goes in here fails at the fetch_object()
}
EDIT:
是否有可能因为我试图查询多个表而不起作用?只有其中一个表具有story_in_lesson_id,即故事表。当我在该表上运行查询时,它可以找到。
EDIT:
更多信息,将数据库复制到我的工作 Mac 上,查询有效!但为什么它在我的电脑上不起作用?顺便说一句,我现在通过在 Sequel Pro 中运行查询来严格测试该查询。
亲爱的,请删除您的位置条件......可能它正在工作,请给我回复您得到的结果。
SELECT *
FROM story st
INNER JOIN sentences s
ON st.sentence_id = s.sentence_id
INNER JOIN speaker sp
ON st.speaker_id = sp.speaker_id
ORDER BY st.story_in_lesson_id ASC
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)