Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres limit param, default to infinite

Tags:

sql

postgresql

I am passing a parameter into a Postgres query which allows the user to set the LIMIT of the result set. This parameter is optional and I would like to set the default LIMIT to infinite (no limit) but I'm not sure what to pass in this case. Would a limit of -1 be viewed as no limit?

like image 319
MattDionis Avatar asked Aug 22 '16 14:08

MattDionis


1 Answers

Quote from the manual

If the count expression evaluates to NULL, it is treated as LIMIT ALL, i.e., no limit

So just pass NULL for the limit and you'll get all rows.

like image 105
a_horse_with_no_name Avatar answered Sep 28 '22 11:09

a_horse_with_no_name