I’m trying to write a query like this, but just can’t seem to work it out:
WHERE
(
meta_key = 'key'
AND
meta_value = 'value' BETWEEN min_value AND max_value
)
AND
(
meta_key = 'different_key'
AND
meta_value = 'different_value' BETWEEN different_min_value AND different_max_value
)
In other words, I want to check if the value of a key is between two numbers AND the value of another key is between two other numbers.
When I use the OR operator, it returns two of the same items, when I just want one.
Help is greatly appreciated!
You need to Join the table twice to test 2 different conditions on 2 rows. This is common (to have a lot of Joins) in EAV designs: