I want my results to show the “page” at a time; I want the page number to be a parameter (in a prepared JDBC statement). Consider the following snippet
SELECT * FROM thread t ORDER BY t.id LIMIT ((? - 1) * 20), 20
Ideally for page 1, this will result in LIMIT 0, 20.
When i test
SELECT * FROM thread t ORDER BY t.id LIMIT ((1 - 1) * 20), 20
They tell me that I have a syntax error. I don’t understand what it can be - it's just simple math. All he tells me is
ERROR 1064 (42000): You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to '((1 - 1) * 20), 20' on line 1
What am I doing wrong with my proposal LIMITand how to fix it?