Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why can't you parameterize the value of a LIMIT clause?

32 views
Skip to first unread message

wiki...@gmail.com

unread,
Mar 8, 2008, 3:02:04 PM3/8/08
to
I don't know if this a bug in MySQL (5), a bug in MyODBC, or if I just
misunderstand parameterization of queries, but insight would be
appreciated!

If I make a parameterized query such as

"Select user from usertable where id=@User LIMIT @Number;"

...it hurls on the @Number. If I replace it with a number in the
query instead of paramterizing it, like this:

"Select user from usertable where id=@User LIMIT 10;"

...then it works just fine. Is this some known limitation or bug, or
should I not expect to be able to make the value of the LIMIT clause a
parameter?

Thanks!
Dave

Rik Wasmus

unread,
Mar 8, 2008, 3:23:34 PM3/8/08
to

http://dev.mysql.com/doc/refman/5.0/en/user-variables.html

"User variables may be used in contexts where expressions are allowed.
This does not currently include contexts that explicitly require a literal
value, such as in the LIMIT clause of a SELECT statement, or the IGNORE N
LINES clause of a LOAD DATA statement."
--
Rik Wasmus

0 new messages