字段列表中临时表的未知列

时间:2021-10-11 00:46:18

I have a temporary table that I have created to exactly match an existing table.

我创建了一个临时表,它与现有表完全匹配。

create temporary table all_plants_temp SELECT * from all_plants;

My goal is to have any changes made to the temporary table all_plants_temp transfer to the original table when needed. To do this, I have been trying to update the original table and set its columns equal to those of the temporary table.

我的目标是在需要时将临时表all_plants_temp的任何更改转移到原始表。为此,我一直在尝试更新原始表,并将其列设置为与临时表相同的列。

update all_plants set all_plants.symbol = all_plants_temp.symbol...(followed by the other columns)...;

Doing this is giving me the following error:

这样做给了我以下的错误:

Error Code: 1054. Unknown column 'all_plants_temp.symbol' in 'field list'

I've tried a number of unsuccessful variations of this code. Because I'm still a novice, I think that I may have a conceptual misunderstanding, but despite searching all over, I can't seem to find my mistake. Any help would be appreciated.

我已经尝试过一些不成功的代码变体。因为我还是个新手,我想我可能有一个概念上的误解,但是尽管到处搜索,我似乎找不到我的错误。如有任何帮助,我们将不胜感激。

EDIT: I forgot to mention that the following query works

编辑:我忘了说下面的查询是有效的

select symbol from all_plants_temp;

1 个解决方案

#1


2  

You could do this by DROP and CREATE table again something as bellow:

你可以通过DROP来完成,然后再创建一个表格,如下所示:

drop table all_plants;

create table all_plants SELECT * from all_plants_temp;

#1


2  

You could do this by DROP and CREATE table again something as bellow:

你可以通过DROP来完成,然后再创建一个表格,如下所示:

drop table all_plants;

create table all_plants SELECT * from all_plants_temp;