Reputation: 4088
I am looking for a solution to use sub query in limit value.
Ex:
SELECT *
FROM `user`
WHERE usertype='6' LIMIT
(SELECT count(*) FROM allowed WHERE usertype='6')
Is there any other way to use a sub Query in LIMIT. I tried the above Query but Its not working.
Upvotes: 1
Views: 64
Reputation: 22915
This is not possible with MySql; you have to use a stored procedure/prepared statement as workaround.
Lots of people have requested this:
http://bugs.mysql.com/bug.php?id=8094
but as you see from the bug listing, this is still open.
EDIT: actually, it seems to have been added in version 5.5.6:
http://bugs.mysql.com/bug.php?id=11918
Upvotes: 1