We just want to write some spatial queries for our PostGIS tables, but we can only write queries with geometry columni like (POINT(36 43). Assume that we have two columns like geom and name, we want write our queries with the point name.

select st_astext(geom) from table
where ST_DWithin (geom, 'POINT (36 43)', 100);

Any ideas about writing these kind of queries without using geometry?

  • 2
    Not really sure what you are trying to do here? Can you explain it more please.
    – Nathan W
    Jul 3, 2012 at 11:37
  • Thanks for your reply. For example i just want to use; select st_astext(geom) from table where ST_DWithin (name, 'pointone', 100); -- i want to use another column to make queries, rather than using geom column.
    – kaankalkan
    Jul 3, 2012 at 15:46
  • Perhaps you need: SELECT ST_AsText(geom) FROM table WHERE ST_DWithin(geom, 'POINT (36 43)', 100) AND name='blabla';
    – Micha
    Jul 4, 2012 at 10:59
  • can i write any variables in point or linestrings like 'POINT(var1 var2)' or "var_about_point" instead of 'POINT(36 43)'? Consider that my variables should come from a related column in my tables. thanks fro answers
    – kaankalkan
    Jul 5, 2012 at 10:20

1 Answer 1


You need to modify the "select" part of your SQL query, so you are selecting the "name" column:

select name, st_astext(geom)
from table
where ST_DWithin(geom, 'POINT (36 43)', 100);

I suggest to learn more about SQL. There are many resources, for example here or here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.