Jump to content

Recommended Posts

Hi

 

I have two tables tbl_users this holds all of the user data including latitude and longitude, and tbl_auction_lot this holds details of items available for auction.

 

i am trying to write a query that displays all of the auction lots within a certain distance

 

This will display the distance, however as soon as I put in * from both tabkes I get syntax errors

 

SELECT ((ACOS(SIN(52.4564772 * PI() / 180) * SIN(latitude * PI() / 180) + COS(52.4564772 * PI() / 180) * COS(latitude * PI() / 180) * COS((-1.7675127 - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance` FROM `tbl_users` INNER JOIN `tbl_auction_lot` on `tbl_auction_lot`.`cust_id`=`tbl_users`.`cust_id` HAVING `distance`<='10' ORDER BY `distance` ASC

 

How can I get other fields displayed, or is it case of listing the fields that I require, rather than * fields

Link to comment
https://forums.phpfreaks.com/topic/267327-mysql-query-help/
Share on other sites

found this via google

 

If your displacements aren't too great (less than a few kilometers) and you're not right at the poles, use the quick and dirty estimate that 111,111 meters in the y direction is 1 degree (of latitude) and 111,111 * cos(latitude) meters in the x direction is 1 degree (of longitude).

 

Link to comment
https://forums.phpfreaks.com/topic/267327-mysql-query-help/#findComment-1371222
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.