比如有一个查询select column from table返回多行数据,我只想取其中的某一条(比如第3行数据),应该怎么写?

解决方案 »

  1.   

    select column from table limit 2,1
      

  2.   

    是随机一行?select column from table order by rand() limit 1;
    指定一行?比如第三行select column from table limit 2,1
      

  3.   

    还可以
    select column from table top 2 not in top 1
      

  4.   


    limit 后面可以跟整型变量吗?因为我要写在存储过程里面
      

  5.   

    很遗憾,不可以跟变量。 看你的应用是什么了,如果允许的话,可以使用 prepare 来执行动态SQL语句来实现。