Is it possible to let MySQL LIMIT have an offset of the total number of rows divided in 2, so that the query would look something like this:
SELECT * FROM test LIMIT COUNT(*) / 2, 5
Where 5 is just a number.
Is it possible to let MySQL LIMIT have an offset of the total number of rows divided in 2, so that the query would look something like this:
SELECT * FROM test LIMIT COUNT(*) / 2, 5
Where 5 is just a number.
It is not possible.
From the documentation:
Expressions can be used at several points in SQL statements, such as in the ORDER BY or HAVING clauses of SELECT statements, in the WHERE clause of a SELECT, DELETE, or UPDATE statement, or in SET statements.
Also from the SELECT documentation:
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).
You will have to do two queries--one to count, the other to limit.