我正在尝试查找索引中存在的行,但是,即使存在与我的索引匹配的行,我的结果也会保持为null。我的查询逻辑有问题吗?
这是我的测试查询:
jQuery("button.compareLoans").click(function() {
jQuery.post(
MyAjax.ajaxurl,
{
action : "myajax-submit",
postID : MyAjax.postID,
data: "amount="+$( "input#loan-amount" ).val()+"&months="+$( "#slider" ).slider( "value" )
},
function( response ) {
$("#content_update").html(response);
}
);
});
在这里,您可以使用查询在{(1}}索引表中找到SELECT `the_products` . *
FROM `the_products`
INNER JOIN `producttypes_index` ON `producttypes_index`.`the_product_id` = `the_products`.`id`
AND `producttypes_index`.`type_id` = '1'
INNER JOIN `producthashtags_index` ON `producthashtags_index`.`the_product_id` = `the_products`.`id`
WHERE
`producthashtags_index`.`producthashtag_id`
IN ('41')
AND
`producthashtags_index`.`producthashtag_id`
IN ('42')
AND
`producthashtags_index`.`producthashtag_id`
IN ('6')
ORDER BY updated_at DESC
54433:
the_product_id
结果:
producthashtags_index
然后你可以看到它也存在于索引表SELECT *
FROM `producthashtags_index`
WHERE `the_product_id` =54433
中使用query:
id producthashtag_id the_product_id
25433 6 54433
25434 41 54433
25435 42 54433
结果:
producttypes_index
答案 0 :(得分:0)
删除
AND `producttypes_index`.`type_id` = '1'
你也可以通过将3 IN变成这样的一个来优化你的代码:
AND `producthashtags_index`.`producthashtag_id` IN('42','41','6')