B
B
beduin012017-04-19 17:12:30
PostgreSQL
beduin01, 2017-04-19 17:12:30

Find out if at least one request was true?

`ST_Contains` returns bool.
Request

SELECT ST_Contains(geometry, ST_SetSRID(ST_POINT(76.8964, 64.4719), 4326)) FROM roads ;

Returns a set of strings for each road. Whether the point hit the road or not.
I don't need each. Whether I need to know the point got to at least one road. How adequate is it to do `ORDER BY ASC` and `LIMIT 1`?
Or are there better solutions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2017-04-19
@Rsa97

bool_or() aggregate function

A
Andrey Burov, 2017-04-19
@BuriK666

SELECT 1 FROM roads WHERE ST_Contains(geometry, ST_SetSRID(ST_POINT(76.8964, 64.4719), 4326)) LIMIT 1;

If at least one record returns, then it is included.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question