How to convert MySQL `LIMIT` clause to PostgreSQL` LIMIT` clause?

Example MySQL query:

    SELECT message_id, message_text
    FROM messages
    LIMIT 0 , 30

      

I am getting this hint as an error:

HINT: Use separate LIMIT and OFFSET clauses.

      

+3


source to share


1 answer


Compare the LIMIT MySQL syntax :

[LIMIT {[offset,] row_count | row_count OFFSET offset}]

      

the one used by Postgres :



[LIMIT { number | ALL }] [OFFSET number]

      

This should give you enough information to change LIMIT 0, 30

to LIMIT 30 OFFSET 0

. (Note that the latter is also MySQL syntax).

+6


source







All Articles