SQLite C++ 比较同一数据库中的两个表以匹配记录
SQLite C++ Compare two tables within the same database for matching records
我希望能够使用C++接口来匹配记录来比较同一SQLite数据库中的两个表。这是我的两个表
表名 : 临时图
ID TEMPTRIGRAM
---------- ----------
1 The cat ran
2 Compare two tables
3 Alex went home
4 Mark sat down
5 this database blows
6 data with a
7 table disco ninja
++78
表名:垃圾邮件三元组
ID TRIGRAM
---------- ----------
1 Sam's nice ham
2 Tuesday was cold
3 Alex stood up
4 Mark passed out
5 this database is
6 date with a
7 disco stew pot
++10000
第一个表有两列和 85 条记录,第二个表有两列,有 10007 条记录。
我想取第一个表并比较 TEMPTRIGRAM 列中的记录,并将其与第二个表中的 TRIGRAM 列进行比较,并返回表中的匹配数。因此,如果 (ID:1 "The Cat Ran" 出现在"spamtrigrams"中,我希望将其计数并在末尾以整数形式返回总计。
有人可以解释一下执行此操作的查询语法吗?
谢谢。
这是一个
带有aggregation
的join
查询。 我的猜测是你想要每trigram
的比赛次数:
select t1.temptrigram, count(t2.trigram)
from table1 t1 left outer join
table2 t2
on t1.temptrigram = t2.trigram
group by t1.temptrigram;
如果您只想要匹配数:
select count(t2.trigram)
from table1 t1 join
table2 t2
on t1.temptrigram = t2.trigram;
相关文章:
- 如何在C++中从两个单独的for循环中添加两个数组
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- 如何返回一个类的两个对象相加的结果
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 两个字符串在 c++ 中不相等
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 两个文件使用彼此的功能-如何解决
- 为什么Mat类的两个对象可以在不重载运算符+的情况下添加
- 如何确保在使用基于布尔值的两个方法之一调用方法时避免分支预测错误
- 停止cmake target_link_libraries将插件中静态库的两个对象文件链接到静态库本身
- 将fold表达式与std::一起用于两个元组
- 如何在C++中比较两个char数组
- 给定两个偶数,求出它们之间所有偶数的平方和
- 比较两个大小不等的映射c++
- C++需要帮助从用户那里获得一个整数,并确保它在另外两个整数之间
- 如何在for循环中包含两个索引值的测试条件
- 在声明中合并两个常量"std::set"(不是在运行时)
- SQLite C++ 比较同一数据库中的两个表以匹配记录