Sql with multiple post_meta statements
-
Hi all,
I need to query my WordPress db based on the posts metadata. No special tricks there. Unfortunately though I need to match for 2 specific statements. Here is my, not working, query so far:
SELECT * FROM wp_postmeta WHERE ( (meta_key = 'lat' AND meta_value >= '60.23457047672217') OR (meta_key = 'lat' AND meta_value <= '60.23457047672217') ) AND ( (meta_key = 'long' AND meta_value >= '24.879140853881836') OR (meta_key = 'long' AND meta_value <= '24.879140853881836') ) GROUP BY post_id
If I remove the “AND” part everything goes well and I get results back only based on the latitude or longitude values. I need to match on both values however.
How can I accomplish this?
Thanks in advance.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Sql with multiple post_meta statements’ is closed to new replies.