PHP顶级故事

PHP顶级故事,php,vote-up-buttons,Php,Vote Up Buttons,我有两张桌子: 故事 ID(int)、内容(text) 投票 ID(int)、类型(int、1或0)、ID_故事(int) 如何让查询返回按投票(=1)描述排序的前10个故事。?我希望能够打印前10个故事的内容 我在这里尝试了很多解决类似问题的方法,但我没能把它做好 SELECT *, count(votes) AS vcount FROM stories s, votes v WHERE s.id=v.id_story AND v.type=1 GROUP BY v.id_sto

我有两张桌子:

故事 ID(int)、内容(text)

投票 ID(int)、类型(int、1或0)、ID_故事(int)

如何让查询返回按投票(=1)描述排序的前10个故事。?我希望能够打印前10个故事的内容

我在这里尝试了很多解决类似问题的方法,但我没能把它做好

SELECT *, count(votes) AS vcount
  FROM stories s, votes v
 WHERE s.id=v.id_story
   AND v.type=1
 GROUP BY v.id_story
 ORDER BY vcount DESC
SELECT 
    storyid,content 
FROM 
    stories 
WHERE 
    storyid IN (
        SELECT 
            storyid,count(votes) AS count 
        FROM 
            stories LEFT JOIN votes ON stories.storyid=votes.storyid 
        WHERE 
            type=1 
            GROUP BY votes.storyid 
            ORDER BY count DESC
)