gpt4 book ai didi

mysql - 多个元查询mysql挂起

转载 作者:行者123 更新时间:2023-11-29 18:01:30 25 4
gpt4 key购买 nike

我正在使用 wp_query我有很多参数需要比较,所以我必须使用多个元查询 (12)

查询创建一个大型 SQL 语句,其中至少包含 12 个 INNER JOINS

此行为使 MYSQL 服务器挂起(即使表非常小)

有解决办法吗?

除了使用 PHP 过滤结果之外?

Array
(
[post_type] => financing
[posts_per_page] => 20
[meta_query] => Array
(
[0] => Array
(
[key] => family_status
[value] => "נשוי"
[compare] => LIKE
)

[1] => Array
(
[key] => has_appartment
[value] => 1
[compare] => =
)

[2] => Array
(
[key] => gender
[value] => "זכר"
[compare] => LIKE
)

[3] => Array
(
[key] => occupational_status
[value] => "שכיר"
[compare] => LIKE
)

[4] => Array
(
[key] => min_in_bank_stage
[value] => 1
[compare] => <=
[type] => NUMERIC
)

[5] => Array
(
[key] => max_children
[value] => 2
[compare] => >=
[type] => NUMERIC
)

[6] => Array
(
[key] => minimum_monthly_income
[value] => 12222
[compare] => <=
[type] => NUMERIC
)

[7] => Array
(
[key] => min_age
[value] => 3
[compare] => <=
[type] => NUMERIC
)

[8] => Array
(
[key] => max_age
[value] => 3
[compare] => >=
[type] => NUMERIC
)

[9] => Array
(
[key] => mortgage_payment_min
[value] => 1222
[compare] => <=
[type] => NUMERIC
)

[10] => Array
(
[key] => mortgage_payment_max
[value] => 1222
[compare] => >=
[type] => NUMERIC
)

[11] => Array
(
[key] => other_payments_amount_min
[value] => 111
[compare] => <=
[type] => NUMERIC
)

[12] => Array
(
[key] => other_payments_amount_max
[value] => 111
[compare] => >=
[type] => NUMERIC
)

)

)

最佳答案

我根据您的发帖结果向您推荐了一个示例。所以,你可以试试这个代码,

<?php
$args = array(
'post_type' => 'financing',
'posts_per_page' => '20',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'family_status',
'value' => 'נשוי',
'compare' => 'LIKE'
),
array(
'key' => 'has_appartment',
'value' => '1',
'compare' => 'EQUAL'
),
array(
'key' => 'gender',
'value' => 'זכר',
'compare' => 'LIKE'
),
continue added more array as per example....
)
);
$search_query = new WP_Query( $args );
$min_max_values = array();
if ( $search_query->have_posts() ) {
while( $search_query->have_posts() ) {
$search_query->the_post();
array_push( $min_max_values, get_the_ID() );
}
}
wp_reset_postdata();
?>

希望,你明白了!!

关于mysql - 多个元查询mysql挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48280540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com