simple SQL request problem
I have two tables.
location which contains the lat,lon and id of some city
poi which contains a list of poi with a unique id
I'm trying to select all the POI inside a radius
SELE开发者_如何学GoCT location.id, longitude, latitude (6371 * acos(cos(radians(46.4166268823293)) * cos(radians(latitude)) * cos(radians(longitude) - radians(-1.5623357632014)) + sin(radians(46.4166268823293)) * sin(radians(latitude)))) AS distance
FROM location,poi
WHERE poi.id = location.id
HAVING distance < 20
ORDER BY distance LIMIT 0 , 20
So i select all the location that are inside my 20km radius. the id of the location is linked to the unique id of the PO table so that's why i'm trying to join the two table
But the join doesn't seem to work. Whe ni try this request on phpMyAdmin it shows only the id,longitute and latitue but it doesn't show field of the POI table (which im intersted in ..)
May somebody can help me? thanks
You didn't select any field of poi. Try SELECT ... poi.* FROM ...
These are the only fields in your select clause. If you do
SELECT POI.*,location.id, longitude, latitude
You would see more
But you do not select a field from POI
, how do you expect this field to be in the result set ?
Select location.id, POI.Field-from-POI, longitude, latitude ...
精彩评论