I want to use
select * from table limit x;
This x can change dynamically. I don't want to use number. There are a solution for limit that use parameter?
I want to use
select * from table limit x;
This x can change dynamically. I don't want to use number. There are a solution for limit that use parameter?
Sure you can. Never needed to myself but:
SELECT * FROM some_table LIMIT (SELECT a_limit FROM other_table);
Obviously that sub-query should only return one row.
To further expand on Richard Huxton's answer, this could be used in a LATERAL sub-query, for example to dynamically limit a K-Nearest Neighbours query:
SELECT loc_id, num_neighbours, neighbour_id
FROM locations,
LATERAL (SELECT neighbour_id
FROM neighbours
ORDER BY ST_distance(locations.geom, neighbours.geom)
LIMIT num_neighbours) knn