Search code examples
postgresqlpostgis

SELECT FROM query with PostGIS geometry not working


I have the following query:

SELECT "coordinate" FROM "chunk" WHERE "coordinate"=ST_SetSRID(ST_MakePoint(1, 1), 4326)

Here I want to select all the rows from a chunk that have a coordinate at (1,1) but I get the following error:

SQL Error [42883]: ERROR: operator does not exist: point = geometry
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
  Position: 52

I would be very happy to see anything that might help me solve this. Thank you in advance.


Solution

  • İf you want search coordinate in "where" section of sql, you should use st_astext function

    Here is the example sql query

    select st_astext(coordinate),coordinate 
    from (
    select 
    1 as id,
    ST_SetSRID(ST_MakePoint(1, 1), 4326) as coordinate
    ) "chunk" 
    where st_astext(coordinate)='POINT(1 1)'