I need to insert a polygon into a postgresql table "polygontable" and then return its (the_geom) value for further querying. I want to be grabbing the most recently inserted instance in "polygontable". How do I call the returned "polygongeom" in a SELECT statement?
INSERT INTO polygontable (the_geom)
VALUES (ST_SetSRID((ST_MakeValid(ST_GeomFromGeoJSON('"+JSON.stringify(payload)+"'))),4326)) returning the_geom as polygon_geom;
SELECT st_intersects(polygon_geom, other_table.the_geom)
from polygon_geom, other_table;