gpt4 book ai didi

mysql - 这种情况如何查询呢?

转载 作者:行者123 更新时间:2023-11-29 14:53:56 26 4
gpt4 key购买 nike

我写了一个question几个小时前关于多对多查询。 Mellamokb 建议:

How about list the categories, and how many posts in each category, sorted from the category with the most posts to the category with the least.

我实际上如何制作查询字符串?我什至不知道从哪里开始。

最佳答案

那么...这是您正在寻找的东西吗?

    SELECT category.name
, COUNT(*) as [Count]
FROM post
INNER JOIN postcategory ON post.id = postcategory.post_id
INNER JOIN category ON postcategory.category_id = category.id
ORDER BY count
GROUP BY category.name

关于mysql - 这种情况如何查询呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5100441/

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