{"id":737,"date":"2025-12-24T15:28:52","date_gmt":"2025-12-24T21:28:52","guid":{"rendered":"https:\/\/thenoyes.com\/littlenoise\/?p=737"},"modified":"2025-12-24T15:32:25","modified_gmt":"2025-12-24T21:32:25","slug":"append-a-point-to-a-linestring-in-mysql","status":"publish","type":"post","link":"https:\/\/thenoyes.com\/littlenoise\/?p=737","title":{"rendered":"Append a Point to a LineString in MySQL"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted has-small-font-size\">SET @ls = LineString(Point(0, 0), Point(0, 1));<br><br>WITH RECURSIVE <br>    nums (n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM nums WHERE n &lt; ST_NumPoints(@ls)), <br>    points (p) as (SELECT ST_PointN(@ls, n) FROM nums UNION ALL SELECT Point(2, 3)) <br>SELECT CAST(ST_Collect(p) AS LINESTRING) INTO @ls FROM points;<br><br>SELECT ST_AsText(@ls);<br><br>+-------------------------+<br>| ST_AsText(@ls)          |<br>+-------------------------+<br>| LINESTRING(0 0,0 1,2 3) |<br>+-------------------------+<br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SET @ls = LineString(Point(0, 0), Point(0, 1));WITH RECURSIVE nums (n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM nums WHERE n &lt; ST_NumPoints(@ls)), points (p) as (SELECT ST_PointN(@ls, n) FROM nums UNION ALL SELECT Point(2, 3)) SELECT CAST(ST_Collect(p) AS LINESTRING) INTO @ls FROM points;SELECT ST_AsText(@ls);+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+| ST_AsText(@ls) |+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+| LINESTRING(0 0,0 1,2 3) |+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[],"class_list":["post-737","post","type-post","status-publish","format-standard","hentry","category-mysql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2IBF1-bT","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=737"}],"version-history":[{"count":2,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/737\/revisions"}],"predecessor-version":[{"id":739,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/737\/revisions\/739"}],"wp:attachment":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}