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 7898581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:28:19+00:00 2026-06-03T08:28:19+00:00

I have a mysql MyISAM table with many rows that contain information about places,

  • 0

I have a mysql MyISAM table with many rows that contain information about places, such as geo coordinates and placenames.

I want to select the nearest place from this table depending given an input latitude and longitude. I want to do this creating a column with points of the geocoordinates, using a spatial index and MBRContains to select the data.

I get an error when selecting the data. I will write down the steps that I did here:

Step 1

ALTER TABLE mytable ADD mypoint Point;

UPDATE  mytable
SET     mypoint = Point(lat, lon);

ALTER TABLE mytable MODIFY mypoint NOT NULL;

CREATE SPATIAL INDEX sx_mytable_coords ON mytable(mypoint );

Result:
I see this in the mypoint column (I’m not sure if that’s oke, but it’s the same for all records): [GEOMETRY - 25Bytes]
I see that the index was added: Name: mypoint Type: SPATIAL Field: mypoint (32) Collation: A

Step 2

I tried to select the data in two ways:

  1. This is recommended for version lower than MySQL 5.1 (My case)

    SET @lat = 40;
    SET @lon = -10;
    
    
    SELECT  *
    FROM    mytable
    WHERE   MBRContains(LineFromText(CONCAT(
            '('
            , @lon + 10 / ( 111.1 / cos(RADIANS(@lon)))
            , ' '
            , @lat + 10 / 111.1
            , ','
            , @lon - 10 / ( 111.1 / cos(RADIANS(@lat)))
            , ' '
            , @lat - 10 / 111.1 
            , ')' )
            ,mypoint)
    

    I get this error:

    1064 – You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near ‘LIMIT 0, 30’ at line 15

  2. This is recommended for version higher than MySQL 5.1

    SET @lat = 40;
    SET @lon = -10;
    
    SELECT  *
        FROM    mytable
        WHERE   MBRContains
                        (
                        LineString
                                (
                                Point
                                        (
                                        @lon + 10 / ( 111.1 / COS(RADIANS(@lat))),
                                        @lat + 10 / 111.1
                                        ) 
                                Point
                                        (
                                        @lon - 10 / ( 111.1 / COS(RADIANS(@lat))),
                                        @lat - 10 / 111.1
                                        ) 
                                ),
                        mypoint
                        )
    

    I get this error:

    1064 – You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near ‘Point ( ‘ at line 12

  • 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-06-03T08:28:21+00:00Added an answer on June 3, 2026 at 8:28 am

    You have a missing bracket, you’re not closing your LineFromText.

    Try:

    SELECT  *
    FROM    mytable
    WHERE   MBRContains(LineFromText(CONCAT(
        '('
        , @lon + 10 / ( 111.1 / cos(RADIANS(@lon)))
        , ' '
        , @lat + 10 / 111.1
        , ','
        , @lon - 10 / ( 111.1 / cos(RADIANS(@lat)))
        , ' '
        , @lat - 10 / 111.1 
        , ')' ))
        ,mypoint)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL MyISAM table with about 400 million rows of price data
I have a MySQL table with about 2 million rows, and a script that
Say you have a MySQL 5.0 MyISAM table with 100 million rows, with one
I have a large mysql MyISAM table with 1.5mil rows and 4.5GB big, still
We have a MyISAM table with approximately 75 milion rows that has 5 columns:
I have a MySQL MyISAM table containing entries that describe airports. This table contains
In a mysql MyISAM table, I have a column type mediumblob and storing captured
I have an older web application that uses a MySQL Database (MYISAM). I noticed
I have a myisam only dedicated 32 GB RAM mysql server that is running
I have MySQL running such that I can open a client command line and

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.