我不清楚你在问什么,但我收集到你想分离center
字段以获得纬度和经度分量。这可以像这样完成:
SELECT
LEFT(center, LOCATE('_', center) - 1) AS latitude,
RIGHT(center, LOCATE('_', center) - 1) AS longitude
FROM earth
更新 1
根据您的评论,您已要求以下标准:
IF Lat <= TopLeftLat && Lat >= BottomRightLat && Lon <= TopLeftLon && Lon >= BottomRightLon
这是您修改后的查询:
SELECT
LEFT(center, LOCATE('_', center) - 1) AS latitude,
RIGHT(center, CHAR_LENGTH(center) - LOCATE('_', center) ) AS longitude
FROM realestate
将条件添加到您的查询中将如下所示(假设TopLeftLat
等是表中的属性):
SELECT a.lat, a.lon
FROM
(SELECT
LEFT(center, LOCATE('_', center) - 1) AS lat,
RIGHT(center, CHAR_LENGTH(center) - LOCATE('_', center) ) AS lon
FROM realestate) a
WHERE a.lat <= TopLeftLat AND a.lat >= BottomRightLat AND a.lon <= TopLeftLon AND a.lon >= BottomRightLon