首页 > 解决方案 > 错误提示“错误代码:1242。子查询返回超过 1 行”

问题描述

我正在尝试插入表,这是我的多对多关系的第三个表,称为“许可证”。我已将插入语句写入存储过程。

我想将 id 是外键的客户和产品表的主键插入到第三个表许可证中,我编写了如下插入语句:

insert into customer`.`tbl_license`(LicenseKey,Quantity,CustomerId,ProductId,Discount) 
                    values((select UUID()),quantity,
(select AutoID from customer.tbl_customer where 
CustomerName=customername),
(select AutoID from customer.tbl_product where 
ProductName=productname),discount);

这个插入语句正确吗?我在插入语句中写了查询

标签: mysql

解决方案


推荐阅读