I have writtern a query in Spatialite to get the nearest line from a point. I want to do that for all points. How can I modify the below codes:
SELECT g1.id As gref_id, g2.id As gnn_gid
FROM CLP_substations As g1, ib5000_contours As g2
where g1.id = 1 and g1.id <> g2.id
ORDER BY ST_Distance(g1.geom,g2.geom)
limit 1