Reputation: 95
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
");
Upvotes: 0
Views: 75
Reputation: 5615
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.
Upvotes: 1