Reputation: 901
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?
Upvotes: 1
Views: 1327
Reputation: 79243
You need to remove the word VALUES
from your query (you insert either values, OR a SELECT result).
Upvotes: 5
Reputation: 237
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.
Upvotes: 2