数据库  mysql
表      art 
字段    id cate addtime已知id
 
求排序后这条记录所在cate下'前面'有多么条记录数和这条记录的cate,按addtime降序一句SQLmysqlsql排序查询

解决方案 »

  1.   

    试一下这个sql:
    select count(id) as '记录数',(select cate from art where id='已知id') as '这条记录的cate' from art where id>='这条记录的cate';
      

  2.   

    后面的按addtime降序,不知何意
      

  3.   

    修改了一下:select count(id) as '记录数',(select cate from art where id='已知id') as '这条记录的cate' from art where id>='已知id';
      

  4.   

    select count(*),x.cate
    from art x,(select * from art order by addtime DESC) temp
    where x.id=the_known_id
    and temp.addtime<x.addtime;试下
      

  5.   

    lz 的问题是不是 查询已知id前面有多少条记录  及 已知id这条记录的所有信息是吧