Skip to content

LIMIT ... OFFSET ... does not work with sqlpage variables in MySQL #1154

@srcarvalho12

Description

@srcarvalho12

I can't use variables defined with "SET" in offset in MariaDB.

error returned from database: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CAST(? AS CHAR) OFFSET CAST(? AS CHAR)' at line 1

I'm defining the variables like this:

set limite = 10;
set offset = (COALESCE($page, 1) - 1) * $limite;

And then I'm trying to use them in the consultation:

...
order by
    id desc
limit $limite
offset $offset;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions