Page 1 of 1

Using a column as a limit... possible?

Posted: Tue Mar 03, 2009 7:19 am
by someberry
Very quick question which doesn't appear to work, but thought I would throw it open to people more clever that me.

I have tried the following, both of which end up with a syntax error. Seems MySQL is expecting a number and nothing else.

Code: Select all

SELECT field_1, field_2
FROM my_table
LIMIT field_3

Code: Select all

SELECT field_1, field_2, (@limit:=(field_3))
FROM my_table
LIMIT @limit

Re: Using a column as a limit... possible?

Posted: Tue Mar 03, 2009 10:36 am
by John Cartwright
Unfortunately, no. Mysql required a constant to be used in the LIMIT clause.