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

この行は、 meta_keymeta_valueがGREATERTHANおよびLESSTHANでAND wpostmeta3.meta_value IS >= '$search_price_min' AND <= '$search_price_max'あることを確認しようとしています。 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 に答える