PHPとMYSQLを使用して、コメント付きのTwitterタイプのフィードを実現しようとしています。
Tweet1
- Comment1 about Tweet1
- Comment2 about Tweet1
Tweet2
- Comment1 about Tweet2
- Comment2 about Tweet2
- Comment3 about Tweet2
Tweet3
- Comment1 about Tweet3
各ツイートの下に関連するコメントを含む「ツイート」をループアウトすることに成功しています。ただし、私の問題は、その特定のツイートに対するコメントの数ごとに「ツイート」をループアウトしていることです。
tweet 1
-comment 1 about tweet1
tweet 1
-comment 1 about tweet 1
-comment 2 about tweet 1 (Tweet 1 has 2 comments so loops out tweet 1 two times)
tweet 2
-comment 1 about tweet 2
tweet 2
-comment 1 about tweet 2
-comment 2 about tweet 2
tweet 2
-comment 1 about tweet 2
-comment 2 about tweet 2
-comment 3 about tweet 2 (Tweet 2 has 3 comments so loops out tweet 2 three times)
結合を使用するのは初めてなので、結合mysqlクエリに問題があると思います
"SELECT tweets.accountno, tweets.id,tweets.tweet,tweets.createdat,tweets.userid,users.name,users.avatar,users.biog,comments.comment FROM tweets INNER JOIN users ON tweets.userid = users.id JOIN comments ON tweets.id = comments.tweetid WHERE tweets.accountno ='123456' ORDER by tweets.ID DESC LIMIT 20"
アイデアはありますか?とても有難い