【发布时间】:2019-01-28 13:34:45
【问题描述】:
我正在尝试获得特定产品的最高报价。这是offer的postmeta:
Array ( [0] => stdClass Object ( [meta_id] => 507752 [post_id] => 95953
[5] => stdClass Object ( [meta_id] => 507757 [post_id] => 95953 [meta_key] => orig_offer_product_id [meta_value] => 2876 )
[9] => stdClass Object ( [meta_id] => 507761 [post_id] => 95953 [meta_key] => orig_offer_amount [meta_value] => 1.00 )
我正在尝试这样的事情:
echo $wpdb->get_var( "select max(orig_offer_amount->meta_value)
from $wpdb->postmeta
where meta_value=2876
and meta_key='orig_offer_product_id'
order by post_id limit 1" );
但它不起作用。
【问题讨论】:
-
出现错误?首先在 phpmyadmin 中尝试您的查询
select max(orig_offer_amount->meta_value) from yourtable where meta_value=2876 and meta_key='orig_offer_product_id' order by post_id limit 1检查是否工作?但是orig_offer_amount->meta_value是什么? -
非常感谢,但我已经解决了问题,见下文。
-
有人可以解释为什么有人给我的问题吗?我是这个网站的新手,我不知道发生了什么。
-
不知道 .... ...
标签: php mysql woocommerce