手机
当前位置:查字典教程网 >编程开发 >mysql数据库 >MySQL实现差集(Minus)和交集(Intersect)测试报告
MySQL实现差集(Minus)和交集(Intersect)测试报告
摘要:可以用SQL实现同样的功能,就是麻烦了点。droptablet1;droptablet2;createtablet1(idintprimar...

可以用SQL实现同样的功能,就是麻烦了点。

drop table t1; drop table t2; create table t1(id int primary key,nickname varchar(20),playNum varchar(20)); create table t2(id int primary key,nickname varchar(20),playNum varchar(20)); insert into t1 values(1,1,10); insert into t1 values(2,2,20); insert into t1 values(3,3,30); insert into t2 values(1,1,10); insert into t2 values(2,2,200); insert into t2 values(3,33,300); commit;

MySQL实现差集(Minus)和交集(Intersect)测试报告1

MySQL实现交集

SELECT id, nickname, playNum, COUNT(*) FROM (SELECT id, nickname, playNum FROM t1 UNION ALL SELECT id, nickname, playNum FROM t2 ) a GROUP BY id, nickname, playNum HAVING COUNT(*) > 1

MySQL实现差集(Minus)和交集(Intersect)测试报告2

MySQL实现差集

SELECT t1.id, t1.nickname, t1.playNum FROM t1 LEFT JOIN t2 ON t1.id = t2.id WHERE t1.nickname != t2.nickname OR t1.playNum != t2.playNum;

MySQL实现差集(Minus)和交集(Intersect)测试报告3

【MySQL实现差集(Minus)和交集(Intersect)测试报告】相关文章:

MySQL里实现类似SPLIT的分割字符串的函数

MySQL 存储过程和"Cursor"的使用方法

MySQL将表a中查询的数据插入到表b中

MYSQL随机抽取查询 MySQL Order By Rand()效率问题

修改MYSQL最大连接数的3种方法分享

MySQL 存储过程的基本用法介绍

win2003服务器下配置 MySQL 群集(Cluster)的方法

MySQL内置时间curdate查询用法

MySQL中的SUM函数使用教程

Mysqlslap MySQL压力测试工具 简单教程

精品推荐
分类导航