运行mysql查询时出现错误。
INSERT INTO raw_table_200(entity_id, master_attribute_id, attribute_value, history_schedule_id, parent_id)
VALUES
((SELECT entity_id FROM raw_table_200 WHERE master_attribute_id = 37),38,(SELECT SUBSTRING_INDEX(attribute_value,' ',-1) FROM raw_table_200 WHERE master_attribute_id=29),223,(SELECT raw_id FROM raw_table_200 WHERE master_attribute_id=31));
================================================ ==========
由mysql服务器发出的错误提示
"You can't specify target table 'raw_table_200' for update in FROM clause"
答案 0 :(得分:0)
如果您无法选择并在同一张表中插入,请尝试以此方式强制构建temo表
INSERT INTO raw_table_200 (entity_id, master_attribute_id, attribute_value, history_schedule_id, parent_id)
select * from (
((SELECT entity_id
FROM raw_table_200 WHERE master_attribute_id = 37)
,38
, (SELECT SUBSTRING_INDEX(attribute_value,' ',-1)
FROM raw_table_200 WHERE master_attribute_id=29)
,223
, (SELECT raw_id FROM raw_table_200 WHERE master_attribute_id=31));
) T