gpt4 book ai didi

Mysql子查询外部Where

转载 作者:行者123 更新时间:2023-11-29 12:57:42 24 4
gpt4 key购买 nike

我正在尝试编写一个 mysql 查询,该查询将找到要通过子查询插入的值,并且仅插入具有指定 mysql id 的行,mysql 给了我这个错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE product_id = '1'' at line 8 

但我现在不知道语法应该是什么,以下是我当前的查询,任何帮助都值得赞赏。

刘易斯

INSERT INTO oc_product 
(tax_class_id)
(
SELECT tax_class_id
FROM oc_tax_class
WHERE title = 'Taxable Goods'
)
WHERE product_id = '1'

编辑:我是个白痴,我应该一直使用更新而不是现在插入它的修复。

最佳答案

如果我正确理解您的问题,我认为您或希望插入 product id = 1 的新行:

INSERT INTO oc_product (product_id, tax_class_id)
SELECT 1, tax_class_id
FROM oc_tax_class
WHERE title = 'Taxable Goods'

关于Mysql子查询外部Where,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23786976/

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