Consider this SQL query:
SELECT * FROM
(
SELECT * FROM wp_postmeta
WHERE
(
meta_key = 'latitude' AND meta_value *1 BETWEEN 47.3641471102 AND 47.3731524898)
OR (meta_key = 'longitude' AND meta_value *1 BETWEEN 8.53253429117 AND 8.54583070883)
)
AS PostMeta, wp_posts
WHERE wp_posts.id = PostMeta.post_id order by post_id asc
It gives me all records that match either latitude between certain values OR the longitude between certain values. What I want to get is the records that match both values. But changing the 'OR' in the query to 'AND' will give me zero results.
I think I need to do a subquery of somekind but dont know how to do it tho.
Anyone?