子查询返回超过1行试图今天和昨天从sku获得价格

时间:2014-08-08 21:04:50

标签: mysql sql

我试图查询数据库以获取今天和昨天的sku价格。 这是我的问题:

select ii2.SKU_config,

(select distinct bsh.unit_price
from tricae_business.bob_stock_history bsh
left join `data_warehouse`.item_info ii0 on ii0.id_item_info = bsh.id_catalog_simple
where date(bsh.date) = DATE_SUB(CURDATE(),INTERVAL 0 day) and ii0.sku_config = sku_config
group by ii0.sku_config) preco_hoje,
(select distinct bsh.unit_price
from tricae_business.bob_stock_history bsh
left join `data_warehouse`.item_info ii1 on ii1.id_item_info = bsh.id_catalog_simple
where date(bsh.date) = DATE_SUB(CURDATE(),INTERVAL 1 day) and ii1.sku_config = sku_config
group by ii1.sku_config) preco_ontem


from `data_warehouse`.item_info ii2
group by sku_config
limit 2

但是我收到了这个错误:

Subquery returns more than 1 row

1 个答案:

答案 0 :(得分:2)

从它的外观来看,你抓住了data_warehouse。item_info ii2中的三列。在您的两个子查询之一中,您可能正在抓取多行,这是不允许的。

尝试自己运行子查询并查看每个子查询返回的内容