question表的字段:question_id,title,contentanswer表的字段answer_id,question_id,content百度了很久,參考著寫了兩條SQL語句:selectquestion.question_id,question.titlefromquestioninnerjoinansweronquestion.question_id=answer.question_idselectquestion_id,titlefromquestionwhere(selectcount(answer.question_id)fromanswerwhereanswer.question_id=question.question_id)>0第一條語句查詢用時1.23s,得到6604條結果,但是有明顯重復,前6個結果為:第二條語句查詢用時34s,得到1188條結果,但是沒有重復,前6個結果為:我在做一個小練習,想把回答數大于0的問題顯示在首頁,請問各位大神,我的SQL語句要如何修改,才能得到回答數大于0的所有問題。另外,我想剛開始在首頁顯示10個問題,看完了,再加載10個問題(當然這些問題都是要求回答數大于0的),這用SQL要怎么做?
MySQL如何查詢回答數大于0的問題并分頁
藍山帝景
2019-05-24 09:43:13