<p>I am writing a stored procedure where I have an input parameter called <em>my_size</em> that is an <em>INTEGER</em>. I want to be able to use it in a <code>LIMIT</code> clause in a <code>SELECT</code> statement. Apparently this is not supported, is there a way to work around this?</p>

<pre><code># I want something like:
SELECT * FROM some_table LIMIT my_size;

# Instead of hardcoding a permanent limit:
SELECT * FROM some_table LIMIT 100;
</code></pre>

A search turned up
this article
.  I've pasted the relevant text below.
Here's a forum post showing an example of prepared statements letting
  you assign a variable value to the limit clause:
http://forums.mysql.com/read.php?98,126379,133966#msg-133966
However, I think this bug should get some attention because I can't
  imagine that prepared statements within a procedure will allow for any
  procedure-compile-time optimizations.  I have a feeling that prepared
  statements are compiled and executed at the runtime of the procedure,
  which probaby has a negative impact on efficiency.  If the limit
  clause could accept normal procedure variables (say, a procedure
  argument), then the database could still perform compile-time
  optimizations on the rest of the query, within the procedure.  This
  would likely yield faster execution of the procedure.  I'm no expert
  though.