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_key price_current
的 meta_value 大于$search_price_min
且LESS只有$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]
答案 0 :(得分:0)
AND <= '$search_price_max'
应该是什么<=
?您错过了该运算符的参数:这是错误。
可能你的意思是:
AND wpostmeta3.meta_value <= '$search_price_max'
答案 1 :(得分: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'