[英]Copying all entries from one table to another with a hard coded value
I currently am copying multiple tables from different mysql schemas into 1 table. 我目前正在将来自不同mysql模式的多个表复制到1个表中。 While trying to copy all of the entries, I am having issues with the "Insert" into temp table.
尝试复制所有条目时,“插入”到临时表时遇到问题。
cua010.doc_table cua010.doc_table
|
| ID |
ID | _FilePath |
_FilePath |
testing.temp_entries testing.temp_entries
|
| ID |
ID | File |
档案| Schema |
架构|
Here is my query 这是我的查询
INSERT INTO testing.temp_entries (File, Schema )
SELECT _FilePath, 'CU010'
FROM cua010.doc_table
In the end I would like to results to be 最后,我希望结果是
|
| ID |
ID | File |
档案| Schema |
架构|
|
| 1 |
1 | test |
测试 cua010 |
cua010 |
|
| 2 |
2 | test2|
测试2 | cua010 |...
cua010 | ...
This is the error message i get 这是我收到的错误消息
0 84 14:49:47 INSERT INTO testing.temp_entries (File, Schema ) SELECT _FilePath, 'cua010' FROM cua010.doc_table Error Code: 1064. You have an error in your SQL
0 84 14:49:47插入testing.temp_entries(文件,架构),从cua010.doc_table中选择_FilePath,“ cua010”。错误代码:1064。您的SQL错误
syntax;句法; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Schema) SELECT _FilePath, 'cua010' FROM cua010.doc_table' at line 1 0.031 sec
在第1行的0.031秒处,检查与您的MySQL服务器版本相对应的手册,以在'Schema)SELECT _FilePath,'cua010'FROM cua010.doc_table'附近使用正确的语法
use "`" around schema (alt +96 in windows) 在模式周围使用“`”(Windows中为Alt +96)
INSERT INTO testing.temp_entries (File, `Schema` )
SELECT _FilePath, 'cua010'
FROM cua010.doc_table ;
Schema is a reserved word. 模式是保留字。
INSERT INTO `testing`.`temp_entries` (`File`, `Schema` )
SELECT `_FilePath`, 'CU010'
FROM `cua010`.`doc_table`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.