例如我上面的问题可以选择B数据库然后执行SELECT * FROM A.member这句SQL语句就可以了?可是不行啊
Insert into DB.b(a, c, d) select a,c,d from DB2.a
我可以这么理解么Insert into 数据库B(表a,表b,表c) selecet 表a,表b,表c from 数据库A?
假设将数据A中table表记录合并至数据库B中table表,通过表中不允许重复的字段来识别,例如username,可以照如下操作: INSERT INTO B.table SELECT * FROM A.table WHERE NOT EXISTS (SELECT * FROM B.table WHERE B.table.username=A.table.username)
不知道你的表结构 不知道你如何确定是新旧记录 当然没有贴完整的代码 你自己变通下就能实现 以主键确定是否重复可用 Insert into DB.b(a, c, d) select a,c,d from DB2.a where DB2.a.id not in (select id from DB.b)
如 SELECT * FROM test.member test是数据库名
若是跨服务器的直接写成sql语句,在用php执行,应该可以吧!直接倒不行就考虑用程序实现吧
INSERT INTO B.table SELECT * FROM A.table WHERE NOT EXISTS (SELECT * FROM B.table WHERE B.table.username=A.table.username)
以主键确定是否重复可用
Insert into DB.b(a, c, d) select a,c,d from DB2.a where DB2.a.id not in (select id from DB.b)