Filipe Filipe - 1 month ago 6
MySQL Question

Does MySQL LIMT not working may have some to do with table structure?

I have a MySQL query working on machine #1 but not on the #2.

The query is:

SELECT
id, vehicle
FROM
requests
WHERE client_id = 8
AND
solved
IS NULL
AND requests_id IS NULL ORDER BY created
DESC LIMIT 10 OFFSET 10


If I take out
LIMIT 10 OFFSET 10
it does work.

I'm wondering if could be something with table's config but I have checked twice and they are basically the same on both servers...

Answer

As you concluded & asked the same

Sorry guys, just found out I haven't more than 10 entries. So that mean OFFSET won't paginate except you have that number of results? ~ @Filipe

Quick Start

Examples

1) $sql = "SELECT * FROM TableName LIMIT 20";

=> Will will return the first 20 records.

2) $sql = "SELECT * FROM TableName LIMIT 10 OFFSET 15";

Or

$sql = "SELECT * FROM TableName LIMIT 15, 10";

=> Will return only 10 records, start on record 16 (OFFSET 15)