私のWebサイトでは、他のソーシャルネットワーキングWebサイトと同様に、ユーザーは更新でき、他のユーザーは更新にコメントできます。
何をしているのか:
query = fetches first name, last name, user id, update id, update post UNION same details for the user who has logged in i.e /* Updates Of Current Logged In User + Updates Of People He Is Following */
loop {
prints first name last name and update
}
後でコメント機能を導入したので、今はループ内でクエリを呼び出し、コメントに対してループを再度実行します。
loop {
prints first name last name and update
commentquery = fetches firstname, last name, user id, comment, of the particulat post
again loop {
prints first/last name of the person who commented, and his comment
}
}
今私によると、これはSQLクエリで達成できると思います。投稿を取得するときに、コメントを一緒に取得できますか、それともこれは正しい方法ですか?問題は、外側のループが実行されると、内側のループも実行されて適切なコメントをフェッチすることです。テーブルを結合して、投稿/更新に関連するコメントを取得できますか?