【发布时间】:2014-12-08 18:54:39
【问题描述】:
我想从catalog_product_entity 表中的每一行获取entity_id 值,并从catalog_product_entity_int 表中的每一行获取每个store_id 值,其中第一个表的entity_id 相等到第二张表的entity_id。
这个 SQL 插入语句有什么问题:
INSERT INTO `catalog_product_entity_varchar` ("","4","231",i.store_id,p.entity_id,"D")
SELECT p.entity_id, i.store_id
FROM catalog_product_entity p
LEFT JOIN catalog_product_entity_int i
ON i.entity_id = p.entity_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 '"","4","231",i.store_id,p.entity_id,"D")
SELECT p.entity_id, i.store_id
FR' at line 1
【问题讨论】:
-
应该是这样的。 INSERT INTO catalog_product_entity_varchar SELECT '',4, 231, i.store_id, p.entity_id, 'D' FROM catalog_product_entity p LEFT JOIN catalog_product_entity_int i ON i.entity_id = p.entity_id;
标签: mysql sql insert phpmyadmin left-join