set @rn=0; 
select @rn:=@rn+1 as rn from (
 select ,m.name,m.code,count(t.key_tech_name) sl from tech_field_code m,data_all t 
 where t.PRO_TECH_FIELD=m.CODE group BY m.name a ORDER BY sl desc,code) a limit 0, 10

解决方案 »

  1.   

    java程序中
    String sql="set @rn=0;select @rn:=@rn+1 as rn from (....";
    rs=db.executeQuery(vsql,null);
    这样会报错You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set @rr=0;select。。
    是不是executeQuery这个方法不支持?
      

  2.   

    你写成一个存储过程,然后直接在java代码里掉存储过程吧
      

  3.   

    http://blog.csdn.net/acmain_chm/article/details/4095531
    MySQL中的ROWNUM的实现
    MySQL 几乎模拟了 Oracle,SQL Server等商业数据库的大部分功能,函数。但很可惜,到目前的版本(5.1.33)为止,仍没有实现ROWNUM这个功能。 下面介绍几种具体的实现方法.建立实验环境如下mysql> create table tbl (    ->  id      int primary key,    ->  col     int    -> );Que...