I currently trying to do a count of how many properties are within a particular price range and the query I am running returns only a value of 1. Obviously I am doing something wrong - and it doesn't help being not so MySQL/PhP savvy.. would anyone mind lending a hand please?
Query is below:
$apart = $wpdb->get_var("SELECT m1.post_id
FROM hj_postmeta m1
INNER JOIN hj_postmeta m2 ON m1.post_id = m2.post_id
WHERE m1.meta_key = 'price'
AND m1.meta_value
BETWEEN 50000 AND 74999 AND m2.meta_key = 'property_type'
AND m2.meta_value = 'apartment'");
$apartprice = count($apart);
Many thanks in advance.
SELECT count(m1.post_id) as count ...