Mega Code Archive

 
Categories / MySQL / Geometric
 

To specify the start and terminal points in Well-Known Text format, a simple SELECT query will suffice

mysql> mysql> mysql> SET @ls = GEOMFROMTEXT('LINESTRING(2 2, 9 0, 9 9)'); Query OK, 0 rows affected (0.00 sec) mysql> mysql> SELECT ASTEXT(STARTPOINT(@ls)), ASTEXT(ENDPOINT(@ls)); +-------------------------+-----------------------+ | ASTEXT(STARTPOINT(@ls)) | ASTEXT(ENDPOINT(@ls)) | +-------------------------+-----------------------+ | POINT(2 2)              | POINT(9 9)            | +-------------------------+-----------------------+ 1 row in set (0.00 sec) mysql>