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
  • 18,365
  • 21
  • 80
  • 122
DonOfDen
  • 3,968
  • 11
  • 62
  • 112

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
  • 22,499
  • 9
  • 75
  • 95