Mysql 内部查询中出错,其中作为内部查询运行时独立生成错误
以下是我的查询,此查询在where子句中给出以下错误Mysql 内部查询中出错,其中作为内部查询运行时独立生成错误,mysql,inner-query,Mysql,Inner Query,以下是我的查询,此查询在where子句中给出以下错误未知列“package\u id” insert into company_packages( package_product_id ,product_id ,company_id ,user_id ,expiry_date ,discount) values( (select id from package_products where package_id=1 and
未知列“package\u id”
insert into company_packages(
package_product_id
,product_id
,company_id
,user_id
,expiry_date
,discount)
values(
(select id from package_products
where package_id=1 and product_id=5 and status=1 limit 1)
,5
,111
,116
,'2015-06-10'
,0)
但是当我运行这个内部查询时,我没有得到任何错误
select id from package_products
where package_id=1 and product_id=5 and status=1 limit 1
而不是此查询
INSERT INTO company_packages(package_product_id,product_id,company_id,user_id,expiry_date,discount)
SELECT id, 5, 111, 116, '2015-06-10', 0
FROM package_products
WHERE package_id=1 AND product_id=5 AND status=1
LIMIT 1
尝试此操作,以避免将
INSERT…值
和INSERT…选择
语法混合使用:
insert into company_packages
(
package_product_id
, product_id
, company_id
, user_id
, expiry_date
, discount
)
select
id
, product_id
, 111
, 116
, '2015-06-10'
, 0
from package_products
where package_id=1
and product_id=5
and status=1
limit 1