1

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.

Sadikhasan
  • 17,858
  • 20
  • 77
  • 117
DonOfDen
  • 3,678
  • 11
  • 58
  • 106

1 Answers1

1

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

davek
  • 21,791
  • 7
  • 74
  • 94