1
我正在使用HTML選擇輸入,並啓用了多個選擇,我正在查看所選選項並嘗試處理我的SQL ...但是,我從SQL中收到一條警告,告訴我如果我的select語句是正確的,我應該使用「SET SQL_BIG_SELECTS = 1」,因爲JOIN超過了限制?SQL_BIG_SELECTS,提煉我的查詢
這裏是我的查詢:
"
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 = 'map_area'
AND ";
$count = 0;
foreach ($params['search_map_area'] as $map_area) :
if ($count != 0) :
$querystr .= "OR ";
endif;
$querystr .= "wpostmeta2.meta_value = '$map_area' ";
$count++;
endforeach;
$querystr .= "AND wpostmeta3.meta_key = 'price_current'
AND wpostmeta3.meta_value BETWEEN $search_price_min AND $search_price_max
AND wposts.post_status = 'publish'
AND wposts.post_type = 'vreb_property'
ORDER BY wposts.post_date DESC
LIMIT 0, 20
";
有沒有更好的方式來查詢呢?這是多次OR wpostmeta2.meta_value = '$map_area'
,似乎導致我的腳本超時......
如果你的選擇是那麼大,我會擔心生成的查詢真的很慢。代碼運行後,查詢看起來像什麼? – Cfreak 2013-02-13 19:45:31
它實際上不運行...它現在超時。即使使用「SET SQL_BIG_SELECTS = 1」 – dcolumbus 2013-02-13 19:46:08