Mladen
Mladen

Reputation: 51

Postgres query can't select specific geolocation

I'm writing some API and I have a stupid problem. If i run a query

SELECT * FROM u.loc

it will list every user location with some data and param "geocode"

ex. "geocode":"(48.2078099,16.3667456)"

(this is in json format only on output not in database)

But if i run a query

SELECT * FROM u.loc WHERE geocode = '(48.2078099,16.3667456)'

It will return empty result. I don't have idea what is the problem here, if somebody know please answer. Thanks

p.s. I'm using PostgreSQL and php, and I don't have direct access to database(pgadmin)

Upvotes: 0

Views: 152

Answers (1)

AbraCadaver
AbraCadaver

Reputation: 79014

You need to supply the exact value "geocode":"(48.2078099,16.3667456)". JSON is not the best format to save in the database.

SELECT * FROM u.loc WHERE geocode = '"geocode":"(48.2078099,16.3667456)"'

Upvotes: 1

Related Questions