SELECT TB.ID, Latitude, Longitude, 111151.29341326 * SQRT( POW( -6 - `Latitude` , 2 ) + POW( 106 - `Longitude` , 2 ) * COS( -6 * 0.017453292519943 ) * COS( `Latitude` * 0.017453292519943 ) ) AS Distance
FROM `tablebusiness` AS TB
JOIN `tablecity` AS TC ON TB.City = TC.City
JOIN `businessestag` AS BC ON BC.BusinessID = TB.ID
JOIN `businessesdistricts` AS BD ON BD.BusinessID = TB.ID
JOIN `tabledistrict` AS TD ON TD.ID = BD.District
WHERE (
`Title` LIKE '%restaurant%'
OR `Street` LIKE '%restaurant%'
OR TB.City LIKE '%restaurant%'
OR BC.Tag LIKE '%restaurant%'
OR TD.District LIKE '%restaurant%'
)
AND (
- 6.0917668133836 < `Latitude`
AND `Latitude` < - 5.9082331866164
AND 105.90823318662 < `Longitude`
AND `Longitude` < 106.09176681338
)
ORDER BY Distance
LIMIT 0, 100
このmysqlは通過しました
それから私も建物に基づいて見たいと思っています。
だから私はやった、誰かが提案したように
SELECT
TB.ID,
Latitude,
Longitude,
111151.29341326 * SQRT(POW(-6 - `TB.Latitude`, 2) + POW(106 - `TB.Longitude`, 2) * COS(-6 * 0.017453292519943) * COS(`TB.Latitude` * 0.017453292519943)) AS Distance
FROM
`tablebusiness` AS TB
JOIN `tablecity` AS TC
ON TB.City = TC.City
JOIN `businessestag` AS BC
ON BC.BusinessID = TB.ID
JOIN `businessesdistricts` AS BD
ON BD.BusinessID = TB.ID
JOIN `tabledistrict` AS TD
ON TD.ID = BD.District
LEFT JOIN `tablebusiness` TBuilding
ON TBuilding.ID = TB.Building
WHERE
(`Title` LIKE '%restaurant%' OR `Street` LIKE '%restaurant%' OR TB.City LIKE '%restaurant%'
OR BC.Tag LIKE '%restaurant%' OR TD.District LIKE '%restaurant%' OR TBuilding.Title LIKE '%restaurant%')
AND (-6.0917668133836 < `TB.Latitude` AND `TB.Latitude` < -5.9082331866164
AND 105.90823318662 < `TB.Longitude` AND `TB.Longitude` < 106.09176681338)
ORDER BY
Distance
LIMIT
0, 100
その後、緯度フィールドがあいまいであるというメッセージを受け取りました。
私は何をすべきか?
私は明らかに結核を追加しました。緯度前
explain SELECT
TB.ID,
TB.Latitude,
TB.Longitude,
111151.29341326 * SQRT(POW(-6 - `TB.Latitude`, 2) + POW(106 - `TB.Longitude`, 2) * COS(-6 * 0.017453292519943) * COS(`TB.Latitude` * 0.017453292519943)) AS Distance
FROM
`tablebusiness` AS TB
JOIN `tablecity` AS TC
ON TB.City = TC.City
JOIN `businessestag` AS BC
ON BC.BusinessID = TB.ID
JOIN `businessesdistricts` AS BD
ON BD.BusinessID = TB.ID
JOIN `tabledistrict` AS TD
ON TD.ID = BD.District
LEFT JOIN `tablebusiness` TBuilding
ON TBuilding.ID = TB.Building
WHERE
(`Title` LIKE '%restaurant%' OR `Street` LIKE '%restaurant%' OR TB.City LIKE '%restaurant%'
OR BC.Tag LIKE '%restaurant%' OR TD.District LIKE '%restaurant%' OR TBuilding.Title LIKE '%restaurant%')
AND (-6.0917668133836 < `TB.Latitude` AND `TB.Latitude` < -5.9082331866164
AND 105.90823318662 < `TB.Longitude` AND `TB.Longitude` < 106.09176681338)
ORDER BY
Distance
LIMIT
0, 100
そして今、エラーは #1054 - 不明な列 'TB.Latitude' in 'field list' です