解决方案:子查询返回多行错误

时间:2018-04-05 09:50:59

标签: mysql subquery

这是我的疑问:

SELECT 

`inv_lc_details`.`lc_date`, `inv_lc_details`.`lc_no`, 
`inv_lc_details`.`lc_amount`,
`inv_proforma_invoice`.`pi_no`, `inv_proforma_invoice_sub`.`pi_goods_des`,
`inv_proforma_invoice_sub`.`pi_amount`,

(SELECT `inv_lc_amend`.`lc_total_amount` FROM `inv_lc_amend` WHERE `inv_lc_amend`.`lc_no`  = `inv_lc_details`.`lc_no`) AS lc_amend_amount,

(SELECT supplier_name FROM inv_supplier_details WHERE inv_supplier_details.supplier_id = `inv_proforma_invoice`.`supplier_id`) AS supplier_name, 

(SELECT `inv_commercial_invoice`.`com_invoice_no` FROM `inv_commercial_invoice` WHERE `inv_commercial_invoice`.`lc_no` = `inv_lc_details`.`lc_no`)AS COM_NO,

(SELECT `inv_commercial_invoice`.`inv_receive_date` FROM `inv_commercial_invoice` WHERE `inv_commercial_invoice`.`lc_no` = `inv_lc_details`.`lc_no`)AS RCV_DATE,

(SELECT `inv_commercial_invoice_sub`.`no_kind` FROM `inv_commercial_invoice`, `inv_commercial_invoice_sub` WHERE `inv_commercial_invoice`.`com_invoice_no` = `inv_commercial_invoice_sub`.`com_invoice_no`) AS NO_KIND

FROM `inv_lc_details`,`inv_proforma_invoice`, `inv_proforma_invoice_sub` 

WHERE 
`inv_lc_details`.`lc_no` = `inv_proforma_invoice`.`lc_no`
AND `inv_proforma_invoice`.`pi_no` = `inv_proforma_invoice_sub`.`pi_no`
AND `inv_lc_details`.`lc_no` = 'lc01'

当我运行此查询时,会生成以下错误消息:

  

子查询返回超过1行。

问题是什么?如何解决?

0 个答案:

没有答案