Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown column of temporary table in field list

Tags:

sql

mysql

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.

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;
like image 566
squared Avatar asked Oct 21 '25 03:10

squared


1 Answers

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

drop table all_plants;

create table all_plants SELECT * from all_plants_temp;
like image 177
rev_dihazum Avatar answered Oct 23 '25 17:10

rev_dihazum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!