SQL语法错误-插入到。。。挑选

SQL语法错误-插入到。。。挑选,sql,Sql,在MySQL Workbench中运行此语句时,SELECT语句附近出现语法错误 INSERT INTO rare_csshop.cscart_product_features_values (feature_id, product_id, value, lang_code) VALUES SELECT DISTINCT "10" As Feature, t1.product_id, CONCAT(t2.NHeigth, "\" H x ", t2.NW

在MySQL Workbench中运行此语句时,SELECT语句附近出现语法错误

INSERT INTO 
    rare_csshop.cscart_product_features_values
        (feature_id, product_id, value, lang_code)
VALUES
    SELECT DISTINCT
    "10" As Feature, t1.product_id, CONCAT(t2.NHeigth, "\" H x ", t2.NWidth, "\" W x ", t2.NDepth, "\" D") As Dimensions, "EN" As Lang
FROM
    rare_csshop.cscart_product_descriptions AS t1, 
    rare_csshop.products AS t2
WHERE
    t1.product = t2.NName

select语句本身运行良好。我遗漏了什么吗?

您需要从查询中删除
值这个词(插入值或选择结果)。

您需要从查询中删除
值这个词(插入值或选择结果)。

在选择语句之前去掉值。这应该行得通

INSERT INTO 
    rare_csshop.cscart_product_features_values
        (feature_id, product_id, value, lang_code)
    SELECT DISTINCT
    "10" As Feature, t1.product_id, CONCAT(t2.NHeigth, "\" H x ", t2.NWidth, "\" W x ", t2.NDepth, "\" D") As Dimensions, "EN" As Lang
FROM
    rare_csshop.cscart_product_descriptions AS t1, 
    rare_csshop.products AS t2
WHERE
    t1.product = t2.NName

我不知道为什么,但我最近才遇到这种情况。可能是当我们指定值时,它只假设值而不是查询结果。

在select语句之前取下值。这应该行得通

INSERT INTO 
    rare_csshop.cscart_product_features_values
        (feature_id, product_id, value, lang_code)
    SELECT DISTINCT
    "10" As Feature, t1.product_id, CONCAT(t2.NHeigth, "\" H x ", t2.NWidth, "\" W x ", t2.NDepth, "\" D") As Dimensions, "EN" As Lang
FROM
    rare_csshop.cscart_product_descriptions AS t1, 
    rare_csshop.products AS t2
WHERE
    t1.product = t2.NName

我不知道为什么,但我最近才遇到这种情况。可能是当我们指定值时,它只假设值而不是查询结果。

欢迎使用Stackoverflow。只是想让您知道,您可以通过选择代码并按Ctrl+K或
{}
按钮来格式化代码。我已经帮你处理好了。欢迎来到Stackoverflow。只是想让您知道,您可以通过选择代码并按Ctrl+K或
{}
按钮来格式化代码。我已经帮你处理好了。