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 7683077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:42:50+00:00 2026-05-31T18:42:50+00:00

I am trying to return records based on the cities that someone chooses. It

  • 0

I am trying to return records based on the cities that someone chooses. It works fine with one city. But I tried to put the “OR” in there and it still only returns results for one city. Not both. Am I doing something wrong here. It looks okay to me but I have to be doing something wrong.

$result = mysql_query("
SELECT 
  lat,lng,id,re,per_num,name,city,state,zip,address,status,category,size,
  ( 3959 * acos( cos( radians(40.000000) ) 
               * cos( radians( lat ) ) 
               * cos( radians( lng ) - radians(-75.000000) ) 
               + sin( radians(40.000000) ) 
               * sin( radians( lat ) ) 
               )
  ) AS distance 
FROM 
  buildings 
WHERE 
  (city='$cities[0]' OR city='$cities[1]') 
  AND re='$re2'
  AND status='$status2' 
  AND size='$size2' 
HAVING 
  distance < 25  
ORDER BY 
  distance 
LIMIT 
  0 , 20  
                     ");
  • 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-31T18:42:51+00:00Added an answer on May 31, 2026 at 6:42 pm

    Your request is constrained not only by your $cities entries but also by

    AND re='$re2' AND status='$status2' AND size='$size2'
    

    And also by

     HAVING distance < 25
    

    May the missing city entrie not comply to any of those constraints, it won’t be in the request result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find records based on a list of id's. But when the
I'm trying to write a method that will return a Hibernate object based on
I'm trying to write a GQL query that returns N random records of a
Im trying to return the value that a $ajax call returns, from a function
Im trying to return a SimpleQuery list that queries a single table and uses
I am trying to return an array Data Member from one smaller 2D Array
I am trying to return the result that I found in my query to
I was trying to implement a download link and put it beside one of
I'm trying to figure out how to make a scope that will return random
I'm trying to get Rails to return a count of the records returned in

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.