Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6335889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:56:38+00:00 2026-05-24T18:56:38+00:00

In my previous question Search for range Latitude/Longitude coordinates My solution was to create

  • 0

In my previous question Search for range Latitude/Longitude coordinates My solution was to create the table below.

mysql> select * from spatial_table where MBRContains(GeomFromText('LINESTRING(9 9, 11 11)'), my_spots);
+------+---------------------------------+
| id   | my_spots    | my_polygons       |
+------+-------------+-------------------+
|    1 |  $@      $@     $@      $@      |
+------+-------------+-------------------+

Now I need to convert and move my existing lat/lng pairs in the table below to spatial_table. How would I structure my query to acheive this? I am currently using the queries below to insert.

mysql> insert into spatial_table values (1, GeomFromText('POINT(1 1)'), GeomFromText('POLYGON((1 1, 2 2, 0 2, 1 1))'));
Query OK, 1 row affected (0.00 sec)

mysql> insert into spatial_table values (1, GeomFromText('POINT(10 10)'), GeomFromText('POLYGON((10 10, 20 20, 0 20, 10 10))') );
Query OK, 1 row affected (0.00 sec)

Existing table:

+-------------+---------+--------+-----------+----- ------+-------------+--------------+
| location_id | country | region |  city     | latitude   | longitude   |     name     |
+=============|=========|========|===========|============|=============|==============|
|   316625    |   US    |   CA   | Santa Cruz|  37.044799 | -122.102096 |  Rio Theatre |
+-------------+---------+--------+-----------+------------+-------------+--------------+    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:56:41+00:00Added an answer on May 24, 2026 at 6:56 pm

    Here is the secret recipe to success 🙂
    My original table:

    mysql> describe gls;
    +-------------+--------------+------+-----+---------+-------+
    | Field       | Type         | Null | Key | Default | Extra |
    +-------------+--------------+------+-----+---------+-------+
    | location_id | int(255)     | NO   | PRI | 0       |       |
    | country     | varchar(255) | NO   |     |         |       |
    | region      | varchar(255) | NO   |     |         |       |
    | city        | varchar(255) | NO   |     |         |       |
    | latitude    | float(13,10) | NO   |     |         |       |
    | longitude   | float(13,10) | NO   |     |         |       |
    +-------------+--------------+------+-----+---------+-------+
    8 rows in set (0.00 sec)
    

    step 1: Add new POINT column

    mysql> alter table gls add my_point point;
    Query OK, 247748 rows affected (4.77 sec)
    Records: 247748  Duplicates: 0  Warnings: 0
    

    Step 2: Update my_point with values from lat/lng fields.

    UPDATE gls SET my_point = PointFromText(CONCAT('POINT(',gls.longitude,' ',gls.latitude,')'));
    

    Step 3: check

    mysql> select aswkt(my_point) from gls where city='Santa Cruz';
    +--------------------------------------+
    | aswkt(my_point)                      |
    +--------------------------------------+
    | POINT(-122.1020965576 37.0447998047) |
    | POINT(-66.25 -12.2833003998)         |
    | POINT(-2.3499999046 42.6666984558)   |
    +--------------------------------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After my previous question (http://stackoverflow.com/questions/8217522/best-way-to-search-for-partial-words-in-large-mysql-dataset), I've chosen Sphinx as the search engine above my
This question follows on from a previous question, that has raised a further issue.
Continuing from my previous question , is there a comprehensive document that lists all
My previous question pertained to the general string search algorithm. I am researching the
This question is based off of the same app/source from my previous question which
this is related to my previous question about jqgrid. im doing now a search
I have search the previous question but couldn't find the answer. Dynamically generated html:
I am testing a solution I tried in a previous question: Use typedef within
In previous question of mine, someone had meantioned that using Semaphores were expensive in
This question is directly related to my previous question ASP.NET AJAX Is it possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.