MySQL Is doing subquery after LIMIT syntax possible? If not, why?

后端 未结 2 1430
野的像风
野的像风 2021-01-24 19:24

I have MySQL Server version 5.1.53. I was looking for an hour to answer this question by myself. Including read the documentation itself at http://dev.mysql.com/doc/refman/5.1/e

2条回答
  •  迷失自我
    2021-01-24 20:16

    From the MySQL manual: http://dev.mysql.com/doc/refman/5.5/en/select.html

    The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants, with these exceptions:

    Within prepared statements, LIMIT parameters can be specified using ? placeholder markers.

    Within stored programs, LIMIT parameters can be specified using integer-valued routine parameters or local variables as of MySQL 5.5.6.

    The MySQL query optimizer needs to resolve the limit parameters to a constant before running the query, or it will not know how many rows to return.

提交回复
热议问题