First look at my database image (the link arrows from one table to another are inner join
's): link
Current Query:
"SELECT
question.*,
questioncomments.*,
login.*
FROM questioncomments
INNER JOIN question
ON questioncomments.comment_question_ID = question.question_ID
INNER JOIN login
ON question.autor_id = login.user_ID
ORDER BY question.question_ID";
Part of my PHP code:
<?php
while($row = $result->fetch_assoc()) {
echo "<hr>[Row 'titulo'] TITLE: " . $row["titulo"] . "<br><br>QUESTION: " . $row["question"] . "<br><br>COMMENT: " . $row["comment"] . "<br><br>";
}
?>
Question:
How to have the comments included in each question_id instead of multiplying each question with each answer?
Expected result (formerly see poor result):
TITLE: Please help me
QUESTION: What is GOOGLE?
COMMENT: is a searcher
COMMENT: is a game
Bad result:
TITLE: Please help me
QUESTION: What is GOOGLE?
COMMENT: is a searcher
TITLE: Please help me
QUESTION: What is GOOGLE?
COMMENT: is a game