MySql Query Limit based on Sub Query Value

DonOfDen

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.

davek

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related