Find the distance between two points in MYSQL. (using the Point Datatype)

后端 未结 3 1089
孤街浪徒
孤街浪徒 2021-01-05 07:39

Suppose I have a 2 column table like this:

| user_id      | int(11) | NO   | UNI | NULL    |                |
| utm          | point   | NO   | MUL | NULL            


        
相关标签:
3条回答
  • 2021-01-05 08:01

    Solved. This is what I did:

    where GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(@mypoint)))) < 9999999999999;
    
    0 讨论(0)
  • 2021-01-05 08:05

    As far as I know, u have to try this way-

    select * from mytable
       where 
        (
            GLength(
              LineStringFromWKB(
                LineString(
                  geoPoint, 
                  GeomFromText('POINT(51.5177 -0.0968)')
                )
              )
            )
          ) < 99999999
    

    More in this answer.

    0 讨论(0)
  • 2021-01-05 08:14

    You can also do it this way. Not sure if it's faster or not.

    select * from mytable where glength(geomfromtext(concat('linestring(', x(utm), ' ', y(utm), ',20 20', ')'))) < 99999999
    
    0 讨论(0)
提交回复
热议问题