• I am using a custom query string that uses meta_key and meta_value to sort the results:

    $querystr = "
        SELECT wposts.*
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id
        AND wpostmeta.meta_key = 'Model'
        AND wpostmeta.meta_value = '$vehicle'
        AND wpostmeta.meta_key = 'Discounted Price'
        AND wpostmeta.meta_value < '$price'
        ORDER BY wposts.post_date DESC
     ";
    $pageposts = $wpdb->get_results($querystr, OBJECT);

    This isn’t working at all, am I missing something really obvious. Any help will be gratefully received.

Viewing 1 replies (of 1 total)
  • Try comparing a value instead of a string.

    Change:
    AND wpostmeta.meta_value < ‘$price’

    To:
    AND wpostmeta.meta_value < $price

    I’m not sure that will work, but everything else looks okay.

    HTH,
    Charles Clarkson

Viewing 1 replies (of 1 total)
  • The topic ‘Advanced query help’ is closed to new replies.