This question already has an answer here:
I have a road lines data in a table with field roads(id SERIAL ,the_line geometry(LineString,4326))
suppose an accident occurs in a middle or at any location in that waterline i want to stop the entire waterline so, given a location or coordinates(POINT(350205.805 148722.56)), I need to find a roadline which is closest to that point. and return its start point and endpoint
"SELECT id, ST_AsText(ST_StartPoint(the_line )) AS startpoint,ST_AsText(ST_EndPoint(the_line )) AS endpoint from roadlines where (some condition to get the closest roadline) close to 'POINT(350205.805 148722.56)'"
POINT(350205.805 148722.56) WILL BE THE INPUT