gpt4 book ai didi

php - 获取每个帖子的最新单个评论

转载 作者:行者123 更新时间:2023-11-29 06:58:04 25 4
gpt4 key购买 nike

获取每篇文章的最新单个评论

   SELECT * 
FROM ( `comments` )
LEFT JOIN `posts`
ON `posts`.`id` = `comments`.`case_id`
WHERE `comments`.`user_id` = '8'
GROUP BY `comments`.`case_id`
ORDER BY `comments`.`created_date` DESC

最佳答案

试试这个,让我知道它是否能回答您的问题:

SELECT * FROM comments 
RIGHT JOIN posts ON posts.id = comments.case_id
WHERE comments.user_id = '8' AND comments.created_date = (SELECT MAX(created_date) FROM comments WHERE case_id = posts.id)

关于php - 获取每个帖子的最新单个评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44803899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com