我有两张表,一张新闻表,一张留言表,通过留言的数据多少进行排序,请给位高手帮哈忙

解决方案 »

  1.   

    select 新闻 from 新闻表 order by (select count(*) from 留言表 where 留言表.新闻ID = 新闻表.新闻ID)
      

  2.   

    最简单普通的思路:留言表记录浏览新闻ID,按留言表中记录的ID分组查询,然后再从新闻表中查询出在留言表被浏览新闻ID出现次数从高到低排序,然后显示就行了。
      

  3.   

    select * from 新闻表,留言表 where 新闻表.新闻id = 留言表.新闻id group by 新闻id order by count(*);
    试试看~~
      

  4.   

    select 新闻.* ,tt.ff from a left join 
    (
    select 留言表.新闻id ,count(*) as ff  from 留言表 group by 新闻id
    ) tt on 新闻表.id = tt.新闻id
    order by ff
      

  5.   

    select *from 新闻表,留言表 where 新闻表.新闻id = 留言表.新闻id group by 新闻id order by ;