Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:26:48+00:00 2026-05-30T03:26:48+00:00

I have a table of users that I want other users to be able

  • 0

I have a table of users that I want other users to be able to search for each other by name. Generally this is easy to a point. However I want users with similar names to show up in order of proximity from one another so lets say therotically I am searching for “Mike” but I don’t know his last name.. What I want my results to show is all the “Mike”‘s in my database starting with the closest one first. I have longitude/latitude for all my users so thats not a problem the problem is the way my query is currently constructed I have to provide a specific range. So I am trying to figure out if theres another way I can construct the query to have no range specified so it will just go from closest to furthest.

Current query looks like

SELECT *,(((acos(sin(($lat*pi()/180)) * sin((`latitude`*pi()/180))+cos(($lat*pi()/180)) * cos((`latitude`*pi()/180)) * cos((($lon - `longitude`)*pi()/180))))*180/pi())*60*1.1515) AS `distance` FROM `memb_geo_locations` HAVING `distance` < $range ORDER BY `distance` ASC"

the flip side to this is also I am likely going to have to form an INNER JOIN with this as the names I’d be searching for are under a different table. where a member_id is the link between the 2 tables. the other table would have
member_id, firstname, lastname
the geo table has
member_id, longitude, latitude, primary

Any idea’s?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:26:49+00:00Added an answer on May 30, 2026 at 3:26 am
    SELECT 
      *,
      (((acos(sin(($lat*pi()/180)) * sin((`latitude`*pi()/180))+cos(($lat*pi()/180)) 
        * cos((`latitude`*pi()/180)) 
        * cos((($lon - `longitude`)*pi()/180))))*180/pi())*60*1.1515) AS `distance` 
    FROM `memb_geo_locations` 
    ORDER BY `distance` DESC
    

    For the first part of your question just remove the HAVING and ORDER BY DESCending.

    Adding the join should be straightforward enough:

    SELECT 
      *,
      (((acos(sin(($lat*pi()/180)) * sin((`latitude`*pi()/180))+cos(($lat*pi()/180)) 
        * cos((`latitude`*pi()/180)) 
        * cos((($lon - `longitude`)*pi()/180))))*180/pi())*60*1.1515) AS `distance` 
    FROM memb_geo_locations 
    INNER JOIN members ON members.member_id = memb_geo_locations.member_id
    WHERE members.firstname LIKE 'bob or whatever%'
    ORDER BY `distance` DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a UISearchDisplayController that allows users to search a table. Currently the
I have a site with users that I want users to be able to
Lets say that I have a table containing users . Each row in that
I have a table with a column that I want to prevent certain users
I have a user table 'users' that has fields like: id first_name last_name ...
Using MySQL, I have a simple table that logs the IP Address that users
i have a table that holds my users information like username , password ,
I have a table that contains articles posted by users. The structure of the
I have a table that contains all the data about users . Users can
I have a table that functions as an event log and stores the users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.