メッセージ/返信アプリケーションを構築しています。アイデアは、メッセージを表示し、返信をそのすぐ下の非表示の div に「show message from ...」というテキストで表示することです。
レイアウト自体に問題はなく、正常に動作していますが、よくわからないのは、単一のメッセージに複数の返信を返す方法です。以下の SQL クエリは私がこれまでに作成したものですが、これによりすべての返信が返されますが、返信ごとにメイン メッセージも繰り返されます。
私の質問は、メイン メッセージを 1 回返し、関連するすべての返信を返すにはどうすればよいですか?
SELECT u.userid, u.first, u.last, c.title, c.body, c.messid,
c.adddate, ru.first, ru.last, cr.body, cr.messreplyid
FROM chat c INNER JOIN users u on u.userid = c.userid
LEFT JOIN chat_reply cr on cr.messid = c.messid
LEFT JOIN users ru on ru.userid = cr.userid
WHERE c.messid =".$_GET['messid']."
GROUP BY cr.messreplyid"
u.userid = the original posters primary key
u.first + u.last = the original posters name
c.title = the title of the post
c.body = the message body
c.messid = the message primary key
c.adddate = message timestamp
ru.first + ru.last = the name of the person who replied
cr.body = the the reply message body
cr.messreplyid = the reply primary key
私が言ったように、2 つの結果が得られるようです。これは、選択内の選択などの複雑なクエリで実行できると確信していますが、助けていただければ幸いです。