我在名为 client
的数据库中有一个名为 user
的表。 user 的结构如下:
`fkey`(varchar(100)) | `status`(enum('1','0'))
我有另一个名为 employees
的数据库,其中有一个名为 employee
的表
它有一个名为 emailid
的列,其中包含我需要的所有数据。
我希望将employees.employee中的所有emailid列数据插入client.user的fkey列中。client.user中还有另一个列状态需要设置为1。如何为此创建查询.
这是我的查询,但它是错误的。
insert into client.user (`fkey`,`status`) select `emailid` from employees.employee,'1';
最佳答案
这绝对是错误的语法。应该是
Insert into client.user (fkey,status) select `emailid`, '1' from employees.employee
关于mysql插入表从另一个数据库选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47386800/