作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个 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/
我是一名优秀的程序员,十分优秀!