Mysql Shell-将选定列从一个表插入到另一个表中

Mysql Shell-将选定列从一个表插入到另一个表中,mysql,shell,Mysql,Shell,我想在数据库中运行查询,然后在另一个数据库中插入结果。 我想做一个脚本,但我不知道如何给它打点 例如: Database 1 : Select name , count(*) as NBName from db1.table1 Database 2 : Insert into table2 values ("test1", 10), ("test2",20) where "test1", 10 ... are the result of the first query. 谢谢:)如果服务器是相

我想在数据库中运行查询,然后在另一个数据库中插入结果。 我想做一个脚本,但我不知道如何给它打点

例如:

Database 1 : Select name , count(*) as NBName from db1.table1
Database 2 : Insert into table2 values ("test1", 10), ("test2",20)
where "test1", 10 ... are the result of the first query.

谢谢:)

如果服务器是相同的,并且您有一个具有适当权限的用户,则只需一条语句即可。在这种情况下,您必须在database.table表单中指定表。它们位于同一服务器中,但用户名/密码不同?你能告诉我更多的细节吗?不同的用户/密码组合。那就不行了。否则您可以使用:
INSERT INTO db2.table2从db1.table1中选择name,COUNT(*)