DonOfDen
DonOfDen

Reputation: 4088

MySql Query Limit based on Sub Query Value

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

Answers (1)

davek
davek

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

Related Questions