CREATE TEMPORARY TABLE bo_attribute_description_group_temp (
SELECT id
FROM bo_attribute_description_group
WHERE display_name IN ('backoffice.attr.group.services', 'backoffice.attr.group.eyecatchergroup')
);
select * from bo_attribute_description_group_temp;
CREATE TEMPORARY TABLE bo_attribute_description_temp (
SELECT id
FROM bo_attribute_description
WHERE group_id IN (bo_attribute_description_group_temp)
);
但它给了我
Error Code: 1054. Unknown column 'bo_attribute_description_group_temp' in 'where clause' 0.000 sec
为什么???
答案 0 :(得分:0)
是的,你可以。您必须在第二个create table子查询中使用select子句:
CREATE TEMPORARY TABLE bo_attribute_description_group_temp (SELECT id
FROM bo_attribute_description_group
WHERE display_name IN ('backoffice.attr.group.services', 'backoffice.attr.group.eyecatchergroup'));
select * from bo_attribute_description_group_temp;
CREATE TEMPORARY TABLE bo_attribute_description_temp (SELECT id
FROM bo_attribute_description
WHERE group_id IN (select id from bo_attribute_description_group_temp));