zoukankan      html  css  js  c++  java
  • MySQL通过POIN数据类型查询指定范围内数据

    情况一:

      数据库:只有point类型的location字段

      实体类:有经纬度字段(double)、originLoction字段(存放string类型的数据库location字段:POINT(123.462202 41.804471)     )

     单位:km

    查询方圆100千米以内的数据..

    SELECT
      *,
      AsText(location) as originLoction,
      (st_distance(location, point(116.397915,39.908946))*111) AS distance
    FROM
      oc_district
    HAVING
      distance<100
    ORDER BY
      distance limit 100;

    情况二:

      数据库:有经度纬度字段,但是没有point字段

      实体类:有经纬度字段(double)、originLoction字段(存放string类型的数据库location字段:POINT(123.462202 41.804471)     )

    以米m为单位

    查询方圆5000m以内的数据

    SELECT

      *,

      (st_distance (point (lng,lat),point (116.3424590000,40.0497810000))*111195/1000 ) as juli

    FROM

      oc_district

    WHERE

      juli <=5000

    ORDER BY

       juli ASC

  • 相关阅读:
    算法笔记--数据结构--并查集
    帮助
    八数码难题神奇!!!
    题解 P1197 【[JSOI2008]星球大战】
    线段树1对于Pushdown的理解
    最短路问题之SPFA
    并查集(路径压缩)
    并查集(KRUSKAL算法)
    初识单调栈
    初识单调队列
  • 原文地址:https://www.cnblogs.com/Soy-technology/p/10981124.html
Copyright © 2011-2022 走看看