简体   繁体   English

将MySQL列从一个表复制到另一个表

[英]Copy MySQL columns from one table to another

I'd like to copy a number of rows from one table to another within phpmyadmin. 我想在phpmyadmin中将许多行从一个表复制到另一个表。 The table i'm copying from is the profile table. 我要复制的表是profile表。 The table user i'm copying to already exists but the columns do not. 我要复制到的表user已经存在,但列不存在。 I'm attempting the following command in the SQL tab of phpmyadmin. 我正在phpmyadmin的SQL选项卡中尝试以下命令。

INSERT INTO user 
   (profileImage, 
   skypeName, 
   facebookProfile, 
   twitterProfile, 
   reputation, 
   genderPreference, 
   agePreference, 
   fluentLanguage, 
   desiredLanguage) 

(SELECT profileImage, skypeName, facebookProfile, twitterProfile, reputation, genderPreference, agePreference, fluentLanguage, desiredLanguage FROM profile)

For some reason this isn't working out for me. 由于某种原因,这对我来说不起作用。 I'm getting an error: 我收到一个错误:

#1054 - Unknown column 'profileImage' in 'field list'

profileImage exists in the profile table, ie it is the name of one of my fields profileImage存在于profile表中,即它是我的字段之一的名称

Does anyone know what the problem might be? 有谁知道可能是什么问题?

If the error is #1054 - Unknown column 'proileImage' in 'field list' then, simply, that column doesn't exist in either (or both) your profile or your user table. 如果错误是#1054 - Unknown column 'proileImage' in 'field list'则该列在您的个人资料或用户表(或两者) 中都不存在。

Just run the select part of the query, ie. 只需运行查询的选择部分即可。 SELECT profileImage, skypeName, facebookProfile, twitterProfile, reputation, genderPreference, agePreference, fluentLanguage, desiredLanguage FROM profile

Does that work? 那样有用吗?

If so, are you sure profileImage exists in the user table? 如果是这样,您确定profileImage在用户表中存在吗?

您可以在phpmyadmin中将表1的结构复制到表2,然后可以运行查询以将表1的某些行复制到表2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM