如何在Mysql中解决这个问题(#1242-子查询返回超过1行)?
我在这里发布了3个问题。实际上我想加入第一个和第二个查询。因为我想把sc.message的结果与我的第二个查询结果集放在一起。请检查我的第三个查询,它给出了上述#1242错误? 请引导我如何在Mysql中解决这个问题(#1242-子查询返回超过1行)?,mysql,sql,mysql-error-1242,Mysql,Sql,Mysql Error 1242,我在这里发布了3个问题。实际上我想加入第一个和第二个查询。因为我想把sc.message的结果与我的第二个查询结果集放在一起。请检查我的第三个查询,它给出了上述#1242错误? 请引导我 Query1=(SELECT sc.message FROM sales_flat_order sfo, `sales_flat_order_item` `sfoi` LEFT JOIN `shipping_comment` `sc` ON `sfoi`.`shipp
Query1=(SELECT sc.message
FROM sales_flat_order sfo, `sales_flat_order_item` `sfoi`
LEFT JOIN `shipping_comment` `sc` ON
`sfoi`.`shipping_comment_id` = `sc`.`shipping_comment_id`
WHERE sfoi.order_id = sfo.entity_id
AND sfo.increment_id = 100000429)
Query2= (SELECT sfoi.name, sfoi.sku, sfoi.qty_ordered, sfoi.price, sfoi.row_total, sfo.base_subtotal,
sfo.base_shipping_amount, sfo.base_grand_total
FROM sales_flat_order sfo
JOIN sales_flat_order_item sfoi
ON sfoi.order_id = sfo.entity_id
WHERE sfo.increment_id = 100000429)
Query3 = SELECT sfoi.name, sfoi.sku, sfoi.qty_ordered, sfoi.price, sfoi.row_total, sfo.base_subtotal,
sfo.base_shipping_amount, sfo.base_grand_total,
(SELECT sc.message
FROM sales_flat_order sfo, `sales_flat_order_item` `sfoi`
LEFT JOIN `shipping_comment` `sc` ON `sfoi`.`shipping_comment_id` = `sc`.`shipping_comment_id`
WHERE sfoi.order_id = sfo.entity_id
AND sfo.increment_id = 100000429)
FROM sales_flat_order sfo
JOIN sales_flat_order_item sfoi
ON sfoi.order_id = sfo.entity_id
WHERE sfo.increment_id = 100000429
那么请告诉我如何解决这个问题
伙计们,我解决了这个问题-:
SELECT sfoi.name, sfoi.sku, sfoi.qty_ordered, sfoi.price,
sfoi.row_total, sfo.base_subtotal, sfo.base_shipping_amount,
sfo.base_grand_total,sc.message
FROM sales_flat_order sfo
JOIN sales_flat_order_item sfoi
ON sfoi.order_id = sfo.entity_id
LEFT JOIN `shipping_comment` `sc`
ON `sfoi`.`shipping_comment_id` = `sc`.`shipping_comment_id`
WHERE sfo.increment_id = 100000429
尝试在第三个查询的最后一行(“WHERE”-行)后添加一个“GROUP BY”-子句。错误是因为子查询与外部查询不相关,但是是的——子查询根本不需要。