gpt4 book ai didi

mysql - 内部查询错误,其中内部查询独立运行时不会产生错误

转载 作者:行者123 更新时间:2023-11-29 00:06:05 26 4
gpt4 key购买 nike

以下是我的查询,此查询给了我以下错误 Unknown column 'package_id' in 'where clause

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

关于mysql - 内部查询错误,其中内部查询独立运行时不会产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27404277/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com