选择另一个数据库表中不存在的记录(Select records that don't exist in another DB table)
我试图解决我认为是一个简单的查询。
我有两个数据库,每个数据库在数据库中都有一个表。
我想要做的是从DB1.Table中找到DB2.Table中不存在的所有电子邮件
我正在使用此查询,但结果不正确,因为我知道DB1.Table包含DB2.Table中不存在的电子邮件(结果始终返回为0)
SELECT DB1.20180320.email FROM DB1.20180320 WHERE DB1.20180319.email NOT IN (SELECT DB2.20180319.email FROM DB2.20180319 WHERE Status = 'active')
我在这里做错了什么想法? 我在每个表格中使用大约80k行。
谢谢。
I'm trying to tackle what I thought was a simple query.
I have two databases each with one table in the DB.
What I would like to do is find all of the emails from DB1.Table that don't exist in DB2.Table
I'm using this query, but the result is incorrect because I know DB1.Table contains emails that don't exist in DB2.Table (result always comes back as 0)
SELECT DB1.20180320.email FROM DB1.20180320 WHERE DB1.20180319.email NOT IN (SELECT DB2.20180319.email FROM DB2.20180319 WHERE Status = 'active')
Any ideas on what I'm doing wrong here? I'm working with about 80k rows in each table.
Thanks.
原文:https://stackoverflow.com/questions/49392610
最满意答案
在分析了它为项目带来的好处以及它如何影响这项工作之后。 使用锁定机制而不是两个Db方法总是更好。
After analyzing what benefit it brings to the project and how it impacts the effort. It was always better for using a locking mechanism rather than a two Db approach.
相关问答
更多-
从C#连接和使用sqlite数据库的最佳方式是什么?(What is the best way to connect and use a sqlite database from C#)[2022-02-01]
SQLite的ADO.NET 2.0提供程序每天有超过200个下载,所以我认为你是安全的使用那个。 ADO.NET 2.0 Provider for SQLite has over 200 downloads every day, so I think you are safe using that one. -
select count(*) from database where message like '%error%' 至于它应该如何在代码中看起来像这样: using(var sda=new SQLiteDataAdapter( "SELECT count(*) from LogDatabase where LogMessage like '%ERR%'", "data source=C:\\TMU_Files\\test31.s3db") { var dt=new DataTable(); ...
-
我认为,如果您将数据库包装在安装程序中,它将提取到Program Files,在这些文件中,您可能无法访问某些用户的写访问权限。 InstallShield应该有一个特殊的伪文件夹来弹出AppData中的数据文件。 您还需要更改程序,以便在那里找到数据库。 我不太记得我害怕的细节。 标记 I think that if you wrap the database in an installer, it will extract to Program Files, in which you might hav ...
-
删除保存数据库的文件。 Delete file, that holds database.
-
查看SQLite pragma-s。 http://www.sqlite.org/pragma.html PRAGMA locking_mode; PRAGMA locking_mode = NORMAL | 独家 该pragma设置或查询数据库连接锁定模式。 锁定模式为NORMAL或EXCLUSIVE。 在NORMAL锁定模式(默认)下,数据库连接在每次读取或写入事务结束时解锁数据库文件。 当锁定模式设置为EXCLUSIVE时,数据库连接永远不会释放文件锁。 第一次以EXCLUSIVE模式读取数据库时,将 ...
-
在分析了它为项目带来的好处以及它如何影响这项工作之后。 使用锁定机制而不是两个Db方法总是更好。 After analyzing what benefit it brings to the project and how it impacts the effort. It was always better for using a locking mechanism rather than a two Db approach.
-
根据我的经验,将尽可能多的数据库调用包装到事务中可以加快速度: using (var db = new SQLiteConnection(dbPath)) { db.RunInTransaction(() => { foreach (var item in items) { db.Insert(item); } }); } From my experience, wrapping as many databas ...
-
如何使用C#或Sqlite查询进行Sqlite数据库备份(How to take Sqlite database backup using C# or Sqlite query)[2022-10-07]
System.Data.SQLite 1.0.74.0已经过时了。 对于备份API支持,至少需要1.0.80.0版本,但您也可以升级到当前版本。 System.Data.SQLite 1.0.74.0 is quite outdated. For the backup API support, at least version 1.0.80.0 would be required, but you could just as well upgrade to a current version. -
好的,我在Xamarin的iOS项目中使用Sqlite.net库。 我创建了一个名为'sqlite-test.db3'的快速而脏的sqlite数据库,其中包含一个名为'users'的表,并添加了3个用户和一些代码进行测试,也许它有所帮助,也许不是,但我让函数执行了120次for a循环没有问题。 我在主代码中的测试循环是 int friendCount = 0; for(int x = 0; x < 120; x++){ friendCount = getCntFriend (); Co ...
-
使用C#查询SQlite数据库时发生ConstraintException(ConstraintException when querying SQlite database with C#)[2023-07-31]
由于Statuses表和Schedule表中的ID列而发生错误。 如果它们不重要,请从两个表中删除列。 I have found a way round this problem. If I select the AccountId from the Schedule table rather than the Accounts table there is no exception thrown. It seems I was unable to run a SELECT statement that c ...