0

Can I run a SQL Query that would compare location of my phone against all locations stored in database?

For example I wanted to search for distance against my current location based on my cellphone's location and show 50m from where I am. (I don't want the Haversine Formula).

I want to know if you can create/write a sql query to take into account the phones current location, so that the results would reflect the users location?

The phone location depending on where it is should communicate with my sql query in a way.

Can I please get some links and explanation so I can start to play around with it myself? :)

Ankhit Sharma
  • 367
  • 1
  • 5
  • 16
  • 1
    The short answer is 'yes'. And before you say, "how do I do it?", remember that questions like that are way too broad and will be closed.you will need to share any code you have tried, and then outline problems you have run into. – Jay Blanchard Apr 23 '15 at 14:31
  • @JayBlanchard, thank you for the comment, I understand in terms of the questions needing to be specific. Is there any link, tutorial, or something...for me to get started with that you can post? That way I can start working on a query and then post meaningful questions :) Any links? – Ankhit Sharma Apr 23 '15 at 14:36
  • The subject is easily searched on Google. A web page is used to create a database request. The web application would have to ask the user to allow their location which can then be sent to a PHP script to use in a query. – Jay Blanchard Apr 23 '15 at 14:44
  • If you ask something like "give me links" then your question will be flagged for being off-topic. So just stop there, be concrete and provide something that shows some effort, like your own non-haversine formula. – inmyth Apr 23 '15 at 14:46
  • @inmyth...I understand your point, I haven't begun my non-haversine formula hence I asked the question. It is just to see if what I was asking was possible. i only ask for links for me to get a starting point where I can then develop my own non-havesine formula. I am new to all of this, I am not asking for someone to do it for me. But thanks for the edits to my question was phrased better :) – Ankhit Sharma Apr 23 '15 at 15:01
  • possible duplicate of [Fastest Way to Find Distance Between Two Lat/Long Points](http://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points) – shA.t Apr 26 '15 at 12:43
  • @shA.t, No I've seen that and I expressed I do not want the Haversine Formula...I am asking something different. – Ankhit Sharma Apr 26 '15 at 18:50

1 Answers1

0

Here's an article containing examples with both php and mySQL implemntation for distance calculation: https://www.marketingtechblog.com/calculate-distance/

I've also found this answer interesting: Fastest Way to Find Distance Between Two Lat/Long Points Looks like you can use mySQL Point datatype and then an internal function called MBRContains to filter the query.

Community
  • 1
  • 1