MySql从另一个减去一个表 [英] MySql Subtract a table from another

查看:199
本文介绍了MySql从另一个减去一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表:A包含所有数据,表B由A随机选择其数据的%25创建.因此,A和B具有完全相同的列.也没有唯一的列.

I have two tables: A contains all the data, table B created from A selecting %25 of its data randomly. So A and B have exact same columns. Also there is no unique column.

我要做的是从A中减去B.有什么想法吗?

What I want to do is subtract B from A. Any ideas?

推荐答案

要查看A中的所有行,但B中的行除外:

To view all rows in A except those in B:

SELECT * FROM A
WHERE (field1, field2, ..., fieldN) NOT IN
( SELECT *
  FROM B
) ;

要从表A中实际删除B中的行:

To actually delete from table A the rows that are in B:

DELETE FROM A
WHERE (field1, field2, ..., fieldN) IN
( SELECT *
  FROM B
) ;

这篇关于MySql从另一个减去一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆