I have two databases: old and new.
Both have a comments table. There are 100 comments in the old table that are not in the new. Comments have been added to the new table and there is a conflict in IDs so querying by ID will not be an option. I need so isolate the 100 comments that that they can be exported and inserted into the new database.
我有两个数据库:旧的和新的。两者都有一个评论表。旧表中有100条注释不在新表中。注释已添加到新表中,并且ID存在冲突,因此不能选择通过ID查询。我需要隔离100条注释,它们可以导出并插入到新数据库中。
I know there are 100 because I have tried using some mysql data compare tools. Unfortunately all of those tools just want to update the comments in the new table with the old content.
我知道有100个因为我尝试过使用一些mysql数据比较工具。不幸的是,所有这些工具只是想用旧内容更新新表中的注释。
Is there a query I can run to get the 100 comments?
我可以运行查询以获得100条评论吗?
1 个解决方案
#1
12
Assuming the tables aren't very large you can run something like this:
假设表不是很大,你可以运行这样的东西:
SELECT *
FROM OldDatabase.CommentTable
WHERE COMMENT NOT IN
(SELECT COMMENT
FROM NewDatabase.CommentTable)
#1
12
Assuming the tables aren't very large you can run something like this:
假设表不是很大,你可以运行这样的东西:
SELECT *
FROM OldDatabase.CommentTable
WHERE COMMENT NOT IN
(SELECT COMMENT
FROM NewDatabase.CommentTable)