WordPress wp_postmeta table is constructed as a key/value pair:
ID | meta_key | meta_value
I need to get the values of two meta_keys within the result set:
property_lat and property_long
I will then use these values to assess the radius of a given point.
Two values in one result set:
SELECT *
FROM wp_postmeta
WHERE meta_key IN ('property_lat', 'property_long')
Two values in one row:
SELECT (SELECT meta_value FROM wp_postmeta WHERE meta_key='property_lat' LIMIT 1) AS lat,
(SELECT meta_value FROM wp_postmeta WHERE meta_key='property_long' LIMIT 1) AS lng
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With