테이블
CREATE TABLE tb_contents(
tc_seq INTEGER NOT NULL AUTO_INCREMENT COMMENT '콘텐츠일련번호',
tc_coordinate POINT NULL COMMENT '콘텐츠좌표',
PRIMARY KEY (tc_seq),
) COMMENT='콘텐츠';
쿼리 예문 : 2가지 계산식
SELECTST_X(TC_COORDINATE) AS coordinatex
, ST_Y(TC_COORDINATE) AS coordinatey
, (
6371 *
ACOS(
COS(RADIANS(ST_Y(TC_COORDINATE))) *
COS(RADIANS(33.51165920146972)) *
COS(RADIANS(126.52084379894258) -
RADIANS(ST_X(TC_COORDINATE))) +
SIN(RADIANS(ST_Y(TC_COORDINATE))) *
SIN(RADIANS(33.51165920146972))
)
) AS distance1 /*거리측정 예1*/
, (SQRT(POW(X(TC_COORDINATE) - 126.52084379894258, 2) + POW(Y(TC_COORDINATE) - 33.51165920146972, 2)) * 111.2 /*Km*/) AS distance2 /*거리측정 예2*/
FROM TB_CONTENTS TC
ORDER BY distance1 ASC
두 가지 계산 결과는 조금 차이가 있었다.