1

When I run this statement within MySQL Workbench, I get a syntax error near the SELECT statement.

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

The select statement runs fine on it's own. Am I missing something?

2 Answers 2

5

You need to remove the word VALUES from your query (you insert either values, OR a SELECT result).

Sign up to request clarification or add additional context in comments.

Comments

2

Take off VALUES before select statement. That should work.

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

I don't know why, but I came across this situation just recently. May be when we specify VALUES, it assumes only values not query results.

1 Comment

Welcome to Stackoverflow. Just wanted to let you know you can format your code by selecting it and either pressing Ctrl+K or the {} button. I took care of it for you already.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.