0
SELECT wposts.*, wpostmeta.*
    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta, $wpdb->postmeta wpostmeta2, $wpdb->postmeta wpostmeta3
    WHERE wposts.ID = wpostmeta.post_id
        AND wposts.ID = wpostmeta2.post_id
        AND wposts.ID = wpostmeta3.post_id
        AND wpostmeta.meta_key = 'listing_subtype'
            AND wpostmeta.meta_value = '$search_home_type'
        AND wpostmeta2.meta_key = 'district'
            AND wpostmeta2.meta_value = '$search_district'
        AND wpostmeta3.meta_key = 'price_current'
            AND wpostmeta3.meta_value IS >= '$search_price_min' AND <= '$search_price_max'
        AND wposts.post_status = 'publish'
        AND wposts.post_type = 'vreb_property'
    ORDER BY wposts.post_date DESC

该行AND wpostmeta3.meta_value IS >= '$search_price_min' AND <= '$search_price_max'试图确保meta_keymeta_value 大于 price_current$search_price_min小于$search_price_max

这行不通...

[You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<= '100000' AND wposts.post_status = 'publish' AND wposts.post_type = 'vreb_' at line 11]
4

2 回答 2

0
AND <= '$search_price_max'

应该是<=什么?您错过了该运算符的论点:这就是错误。

可能你的意思是:

AND wpostmeta3.meta_value <= '$search_price_max'
于 2013-01-23T01:17:43.910 回答
0
AND wpostmeta3.meta_value IS >= '$search_price_min' AND <= '$search_price_max'

需要是

AND wpostmeta3.meta_value >= '$search_price_min'
AND wpostmeta3.meta_value <= '$search_price_max'
于 2013-01-23T01:18:52.460 回答