0

Consider simple query:

SELECT * FROM `your_table` LIMIT 0, 10

Can I have 10 value coming from another settings table?

If yes, is it beneficial faster to do this, or rather have settings table in php, and set value 10 during query?

  • Retrieving another value from a table to use inside `LIMIT` is going to be tricky. It will be a lot less trouble to do it in PHP. It's only one extra query - be sure to store the value in a PHP variable for future use, rather than requery it. – Michael Berkowski Oct 27 '13 at 21:47
  • Unfortunately not, see http://stackoverflow.com/questions/6312638/mysql-is-doing-subquery-after-limit-syntax-possible-if-not-why – pcreech Oct 27 '13 at 21:47
  • 1
    For what it's worth, it could be done by building it in a stored procedure, but so much easier to do it application-side in PHP. – Michael Berkowski Oct 27 '13 at 21:48

1 Answers1

0

Probably it depends on what SQL server do you use, but the standart SQL syntax would not let you have the limit value read from another "settings" table.

So better define it in the PHP code and use it when you build your SQL query.

Lachezar
  • 6,523
  • 3
  • 33
  • 34