Azu Posted July 14, 2007 Share Posted July 14, 2007 Hi, could somebody please tell me how to do this? Something like select * from row where x,y,z is closest to 1,2,3 I have a table with x y z coordinates in it and I want to select select from there whichever one is closest.. Link to comment https://forums.phpfreaks.com/topic/59949-solved-select-closest-to/ Share on other sites More sharing options...
Wildbug Posted July 14, 2007 Share Posted July 14, 2007 Pythagorean theorem. SELECT *, SQRT(POW(x-xcol,2) + POW(y-ycol,2) + POW(z-zcol,2)) AS distance FROM table ORDER BY distance LIMIT 1; Link to comment https://forums.phpfreaks.com/topic/59949-solved-select-closest-to/#findComment-298292 Share on other sites More sharing options...
Azu Posted July 16, 2007 Author Share Posted July 16, 2007 Thanks you're a genius it works perfectly. Link to comment https://forums.phpfreaks.com/topic/59949-solved-select-closest-to/#findComment-299120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.